ckeck account already exists or not When import keystore

This commit is contained in:
JKinGithub 2019-11-26 16:58:32 +08:00 committed by GitHub
parent 8c1e8de839
commit cf27bc244f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
}