How come accounts doesn't persist between runs

Every time I run

./scripts/cli/start_cli_testnet.sh

any account I created previously is gone.

I’ll need to do account create to get back any existing account.

Why is it like this?

Hi yadakhov, please check the following post My First Transaction

@yadakhov, you can save the accounts via the save sub-command under the account command of the CLI and then load them via the load sub-command

Hi @yadakhov, the behavior of libra-cli may be some strange in term of wallet, behind the scene account create use /client.mnemonic that persist in your environment and use key_factory to generate your address (address, public key and private key).

You can think account create as pseudo code create_account(mnemonic, '/wallet/0') for first wallet and create_account(mnemonic, '/wallet/1') for second wallet and so on, so that’s deterministic (result is the same everytime). That why you can always get access to your address by account create again without persistence of private keys.

You can check this code for the detail https://github.com/libra/libra/blob/master/client/libra_wallet/src/key_factory.rs#L183

3 Likes