aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/account_manager.go
diff options
context:
space:
mode:
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) {