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 /accounts/keystore | |
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 'accounts/keystore')
-rw-r--r-- | accounts/keystore/keystore_passphrase.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/accounts/keystore/keystore_passphrase.go b/accounts/keystore/keystore_passphrase.go index 535608a60..eaec39f7d 100644 --- a/accounts/keystore/keystore_passphrase.go +++ b/accounts/keystore/keystore_passphrase.go @@ -28,6 +28,7 @@ package keystore import ( "bytes" "crypto/aes" + crand "crypto/rand" "crypto/sha256" "encoding/hex" "encoding/json" @@ -90,6 +91,12 @@ func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string) return key, nil } +// StoreKey generates a key, encrypts with 'auth' and stores in the given directory +func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) { + _, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP}, crand.Reader, auth) + return a.Address, err +} + func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) error { keyjson, err := EncryptKey(key, auth, ks.scryptN, ks.scryptP) if err != nil { |