aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/account_manager.go
diff options
context:
space:
mode:
authorAles Katona <ales@coinbase.com>2016-04-26 01:23:40 +0800
committerAles Katona <ales@coinbase.com>2016-04-28 23:11:40 +0800
commit572da73d4d475db0443f457d9383a3d513f189ee (patch)
treee5a13000b505ebc2576e58e6c371da8838d56f40 /accounts/account_manager.go
parent70b8b54cd2413fb01e279890b2ddb5eb9bc227c2 (diff)
downloaddexon-572da73d4d475db0443f457d9383a3d513f189ee.tar
dexon-572da73d4d475db0443f457d9383a3d513f189ee.tar.gz
dexon-572da73d4d475db0443f457d9383a3d513f189ee.tar.bz2
dexon-572da73d4d475db0443f457d9383a3d513f189ee.tar.lz
dexon-572da73d4d475db0443f457d9383a3d513f189ee.tar.xz
dexon-572da73d4d475db0443f457d9383a3d513f189ee.tar.zst
dexon-572da73d4d475db0443f457d9383a3d513f189ee.zip
eth: add personal_importRawKey for runtime private key import
Diffstat (limited to 'accounts/account_manager.go')
-rw-r--r--accounts/account_manager.go7
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) {