soroban-cli icon indicating copy to clipboard operation
soroban-cli copied to clipboard

`keys generate`: don't overwrite existing account

Open chadoh opened this issue 1 year ago • 6 comments
trafficstars

What problem does your feature solve?

Right now if you have an existing account named alice and you run keys generate again, it will generate a new account, overwrite the old alice.toml file with the new seed phrase, and fund the new account.

$ cat .soroban/identity/alice.toml
───────┬────────────────────────────────────
       │ File: .soroban/identity/alice.toml
───────┼────────────────────────────────────
   1   │ seed_phrase = "zoo solid..."
───────┴────────────────────────────────────
$ soroban keys generate alice --network local
$ cat .soroban/identity/alice.toml
───────┬────────────────────────────────────
       │ File: .soroban/identity/alice.toml
───────┼────────────────────────────────────
   1   │ seed_phrase = "camp endorse..."
───────┴────────────────────────────────────

What would you like to see?

By default

  • check if the account exists and is funded above some level
  • If it's not sufficiently funded, fund it (see #1389)
  • mention that if you want to regenerate the account with a new seed phrase, you can keys rm first

Here's an example of what this could look like:

$ soroban keys generate alice --network local
alice already exists!
    seed phrase found at: /path/to/.soroban/identity/alice.toml
    current XLM balance: 231
Balance >100 XLM, nothing to do. 
To generate new keys for alice, you can `keys rm alice` first.

Or, if the account doesn't have sufficient balance:

$ soroban keys generate alice --network local
alice already exists!
    seed phrase found at: /path/to/.soroban/identity/alice.toml
    account XLM balance: 9
Topping off... Balance is now 1009 XLM.
To generate new keys for alice, you can `keys rm alice` first.

What alternatives are there?

With #1389, we're considering adding a --minimum-balance option. I think for the sake of clarity & simplicity, we do NOT add that to keys generate. But should we mention the existence of keys fund in the output here?

chadoh avatar Jun 17 '24 19:06 chadoh