diff options
author | Ales Katona <ales@coinbase.com> | 2016-04-26 01:23:40 +0800 |
---|---|---|
committer | Ales Katona <ales@coinbase.com> | 2016-04-28 23:11:40 +0800 |
commit | 572da73d4d475db0443f457d9383a3d513f189ee (patch) | |
tree | e5a13000b505ebc2576e58e6c371da8838d56f40 /accounts | |
parent | 70b8b54cd2413fb01e279890b2ddb5eb9bc227c2 (diff) | |
download | go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.gz go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.bz2 go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.lz go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.xz go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.tar.zst go-tangerine-572da73d4d475db0443f457d9383a3d513f189ee.zip |
eth: add personal_importRawKey for runtime private key import
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/account_manager.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/accounts/account_manager.go b/accounts/account_manager.go index 56499672e..3afadf6b2 100644 --- a/accounts/account_manager.go +++ b/accounts/account_manager.go @@ -284,7 +284,12 @@ func (am *Manager) Import(keyJSON []byte, passphrase, newPassphrase string) (Acc // ImportECDSA stores the given key into the key directory, encrypting it with the passphrase. func (am *Manager) ImportECDSA(priv *ecdsa.PrivateKey, passphrase string) (Account, error) { - return am.importKey(newKeyFromECDSA(priv), passphrase) + key := newKeyFromECDSA(priv) + if am.cache.hasAddress(key.Address) { + return Account{}, fmt.Errorf("account already exists") + } + + return am.importKey(key, passphrase) } func (am *Manager) importKey(key *Key, passphrase string) (Account, error) { |