diff options
author | Martin Holst Swende <martin@swende.se> | 2017-11-21 00:39:53 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-11-21 00:39:53 +0800 |
commit | bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5 (patch) | |
tree | 69450c1c69b418ad9040d58cf9d2e2584bd27e07 /cmd | |
parent | b4f2e4de8fcbaab22f1b8ac1faa0c99517bd9405 (diff) | |
download | dexon-bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5.tar.gz dexon-bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5.tar.zst dexon-bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5.zip |
cmd/geth: make geth account new faster with many keys (#15529)
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/accountcmd.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go index 0f53c92b0..0db5c4ce0 100644 --- a/cmd/geth/accountcmd.go +++ b/cmd/geth/accountcmd.go @@ -291,15 +291,28 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr // accountCreate creates a new account into the keystore defined by the CLI flags. func accountCreate(ctx *cli.Context) error { - stack, _ := makeConfigNode(ctx) + cfg := gethConfig{Node: defaultNodeConfig()} + // Load config file. + if file := ctx.GlobalString(configFileFlag.Name); file != "" { + if err := loadConfig(file, &cfg); err != nil { + utils.Fatalf("%v", err) + } + } + utils.SetNodeConfig(ctx, &cfg.Node) + scryptN, scryptP, keydir, err := cfg.Node.AccountConfig() + + if err != nil { + utils.Fatalf("Failed to read configuration: %v", err) + } + password := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx)) - ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - account, err := ks.NewAccount(password) + address, err := keystore.StoreKey(keydir, password, scryptN, scryptP) + if err != nil { utils.Fatalf("Failed to create account: %v", err) } - fmt.Printf("Address: {%x}\n", account.Address) + fmt.Printf("Address: {%x}\n", address) return nil } |