From 95a3878474a4a8e0c8dbf8726bfb5213abab5b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 4 Jun 2020 08:59:26 +0300 Subject: [PATCH] acounts/keystore, cmd/faucet: fix faucet double import, fix twitter url # Conflicts: # cmd/faucet/faucet.go --- accounts/keystore/keystore.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go index c3eba1232..9956f75b3 100644 --- a/accounts/keystore/keystore.go +++ b/accounts/keystore/keystore.go @@ -42,6 +42,10 @@ var ( ErrLocked = accounts.NewAuthNeededError("password or unlock") ErrNoMatch = errors.New("no key for given address or file") ErrDecrypt = errors.New("could not decrypt key with given password") + + // ErrAccountAlreadyExists is returned if an account attempted to import is + // already present in the keystore. + ErrAccountAlreadyExists = errors.New("account alreaady exists") ) // KeyStoreType is the reflect type of a keystore backend. @@ -440,7 +444,7 @@ func (ks *KeyStore) Import(keyJSON []byte, passphrase, newPassphrase string) (ac ks.importMu.Lock() defer ks.importMu.Unlock() if ks.cache.hasAddress(key.Address) { - return accounts.Account{}, errors.New("account already exists") + return accounts.Account{}, ErrAccountAlreadyExists } return ks.importKey(key, newPassphrase) } @@ -451,7 +455,7 @@ func (ks *KeyStore) ImportECDSA(priv *ecdsa.PrivateKey, passphrase string) (acco ks.importMu.Lock() defer ks.importMu.Unlock() if ks.cache.hasAddress(key.Address) { - return accounts.Account{}, errors.New("account already exists") + return accounts.Account{}, ErrAccountAlreadyExists } return ks.importKey(key, passphrase) }