diff --git a/accounts/keystore/key.go b/accounts/keystore/key.go index 56ec48f3bb..84d8df0c5a 100644 --- a/accounts/keystore/key.go +++ b/accounts/keystore/key.go @@ -179,8 +179,6 @@ func storeNewKey(ks keyStore, rand io.Reader, auth string) (*Key, accounts.Accou zeroKey(key.PrivateKey) return nil, a, err } - fmt.Printf("Your new key is generated. Please backup the key file: %s\n", a.URL) - return key, a, err } diff --git a/accounts/keystore/passphrase.go b/accounts/keystore/passphrase.go index a0b6cf5385..1ced41e997 100644 --- a/accounts/keystore/passphrase.go +++ b/accounts/keystore/passphrase.go @@ -38,6 +38,7 @@ import ( "os" "path/filepath" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" @@ -97,9 +98,9 @@ func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string) } // StoreKey generates a key, encrypts with 'auth' and stores in the given directory -func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) { +func StoreKey(dir, auth string, scryptN, scryptP int) (accounts.Account, error) { _, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP, false}, rand.Reader, auth) - return a.Address, err + return a, err } func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) error { diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go index 940290899c..666ed63b12 100644 --- a/cmd/geth/accountcmd.go +++ b/cmd/geth/accountcmd.go @@ -307,12 +307,13 @@ func accountCreate(ctx *cli.Context) error { password := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx)) - address, err := keystore.StoreKey(keydir, password, scryptN, scryptP) + account, err := keystore.StoreKey(keydir, password, scryptN, scryptP) if err != nil { utils.Fatalf("Failed to create account: %v", err) } - fmt.Printf("Address: {%x}\n", address) + fmt.Printf("Your new key is generated. Please backup the key file: %s\n", account.URL.Path) + fmt.Printf("Address: {%x}\n", account.Address) return nil }