nervosnetwork / ckb-cli

CKB command line interface
MIT License
55 stars 35 forks source link

Add `account remove` command #366

Closed e00dan closed 3 years ago

e00dan commented 3 years ago

As I was learning about Nervos I mistyped password when importing genesis account. It turns out, that you can't override account that you already imported with error: "Key already exists.", so it was basically game over if I'd like to stick to CLI commands, because I didn't know the password and couldn't fix it.

I think there should be new subcommand added to the account section called remove which removes already added account. Thanks to this, you could be able to import the private key again and reset password.

I fixed this locally by going to ~/.ckb-cli and manually removing keystore files, but to find this directory I had to dive into the source code.

To find an analogy to the rest of ecosystem - if we look at official Geth documentation one of the main tabs mentions how keystores are handled and therefore it gives an idea how accounts can be added/removed: https://geth.ethereum.org/docs/clef/tutorial

TheWaWaR commented 3 years ago

Remove account is a very dangerous operation, user may lost their private key accidentally. As I know geth also not allow user delete their key though geth command, but geth do print the key file path.

How about add an account remove sub-command and it's behavior isn't remove the keystore, instead print the keystore path and tell user how to remove the keystore?

e00dan commented 3 years ago

I think such command would definitely be helpful, even if it's only printing the path. :)