From cf27bc244f57e299cb05e0c9b39f406b61af1404 Mon Sep 17 00:00:00 2001 From: JKinGithub <41677975+JKinGH@users.noreply.github.com> Date: Tue, 26 Nov 2019 16:58:32 +0800 Subject: [PATCH] ckeck account already exists or not When import keystore --- accounts/keystore/keystore.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go index 5b55175b1f..28669a61a4 100644 --- a/accounts/keystore/keystore.go +++ b/accounts/keystore/keystore.go @@ -443,6 +443,9 @@ func (ks *KeyStore) Import(keyJSON []byte, passphrase, newPassphrase string) (ac if err != nil { return accounts.Account{}, err } + if ks.cache.hasAddress(key.Address) { + return accounts.Account{}, fmt.Errorf("account already exists") + } return ks.importKey(key, newPassphrase) }