How does geth create a new account?

If you want to start learning Ethereum DApp development right away, you can visit the excellent online interactive tutorial provided by Huizhi.com:

Use geth's account command to manage accounts, such as creating new accounts, updating account passwords, querying accounts, etc.:

geth account <command> [options...] [arguments...]

command - command

list    列表显示现有账户
new     创建一个新的账户
update  修改账户
import  导入私钥创建新账户

--helpHelp for these commands can be obtained using, for example:

~$ geth account list --help
list [command options] [arguments...]

Print a short summary of all accounts

OPTIONS:
  --datadir "/home/bas/.ethereum"  Data directory for the databases and keystore
  --keystore                       Directory for the keystore (default = inside the datadir)

Create new account

geth account newCreate a new account using the command:

$ geth account new
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat Passphrase:
Address: {168bc315a2ee09042d83d7c5811b533620531f67}

Import the private key to create a new account

A new account can be created by importing the private key using the geth account importcommand,

~$ geth account import --datadir /someOtherEthDataDir ./key.prv
The new account will be encrypted with a passphrase.
Please enter a passphrase now.
Passphrase:
Repeat Passphrase:
Address: {7f444580bfef4b9bc7e14eb7fb2a029336b07c9d}

Update account password

Use the geth account updatecommand to update the password of the specified account:

~$ geth account update a94f5374fce5edbc8e2a8697c15331677e6ebf0b
Unlocking account a94f5374fce5edbc8e2a8697c15331677e6ebf0b | Attempt 1/3
Passphrase:
0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b
Account 'a94f5374fce5edbc8e2a8697c15331677e6ebf0b' unlocked.
Please give a new password. Do not forget this password.
Passphrase:
Repeat Passphrase:
0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b

Show existing accounts

Use the geth account listcommand list to display existing accounts, and optionally --keystorespecify the keystore directory:

~$ geth account list --keystore /tmp/mykeystore/
Account #0: {5afdd78bdacb56ab1dad28741ea2a0e47fe41331} keystore:///tmp/mykeystore/UTC--2017-04-28T08-46-27.437847599Z--5afdd78bdacb56ab1dad28741ea2a0e47fe41331
Account #1: {9acb9ff906641a434803efb474c96a837756287f} keystore:///tmp/mykeystore/UTC--2017-04-28T08-46-52.180688336Z--9acb9ff906641a434803efb474c96a837756287f

Original: geth account management guide

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325474403&siteId=291194637