From 572da73d4d475db0443f457d9383a3d513f189ee Mon Sep 17 00:00:00 2001 From: Ales Katona Date: Mon, 25 Apr 2016 11:23:40 -0600 Subject: eth: add personal_importRawKey for runtime private key import --- accounts/account_manager.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'accounts') 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) { -- cgit