aboutsummaryrefslogtreecommitdiffstats
path: root/accounts
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2017-11-21 00:39:53 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-11-21 00:39:53 +0800
commitbedf6f40aff0dd14bfab533a37c329ddc9a4bdd5 (patch)
tree69450c1c69b418ad9040d58cf9d2e2584bd27e07 /accounts
parentb4f2e4de8fcbaab22f1b8ac1faa0c99517bd9405 (diff)
downloadgo-tangerine-bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5.tar.gz
go-tangerine-bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5.tar.zst
go-tangerine-bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5.zip
cmd/geth: make geth account new faster with many keys (#15529)
Diffstat (limited to 'accounts')
-rw-r--r--accounts/keystore/keystore_passphrase.go7
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 {