aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Schlatter <jeremy.schlatter@gmail.com>2019-01-07 16:35:44 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-01-07 16:35:44 +0800
commitaca588a8e434cd0409c44d55b6009fb74e913537 (patch)
treeda5c1d58339b73dc671d39c5764ddaa624298906
parentfe03b76ffe9f9d48b09f4d93f18fae1e5ad4c1f4 (diff)
downloadgo-tangerine-aca588a8e434cd0409c44d55b6009fb74e913537.tar
go-tangerine-aca588a8e434cd0409c44d55b6009fb74e913537.tar.gz
go-tangerine-aca588a8e434cd0409c44d55b6009fb74e913537.tar.bz2
go-tangerine-aca588a8e434cd0409c44d55b6009fb74e913537.tar.lz
go-tangerine-aca588a8e434cd0409c44d55b6009fb74e913537.tar.xz
go-tangerine-aca588a8e434cd0409c44d55b6009fb74e913537.tar.zst
go-tangerine-aca588a8e434cd0409c44d55b6009fb74e913537.zip
accounts/keystore: small code simplification (#18394)
-rw-r--r--accounts/keystore/wallet.go20
1 files changed, 4 insertions, 16 deletions
diff --git a/accounts/keystore/wallet.go b/accounts/keystore/wallet.go
index 60044b1f9..2f774cc94 100644
--- a/accounts/keystore/wallet.go
+++ b/accounts/keystore/wallet.go
@@ -84,10 +84,7 @@ func (w *keystoreWallet) SelfDerive(base accounts.DerivationPath, chain ethereum
// able to sign via our shared keystore backend).
func (w *keystoreWallet) SignHash(account accounts.Account, hash []byte) ([]byte, error) {
// Make sure the requested account is contained within
- if account.Address != w.account.Address {
- return nil, accounts.ErrUnknownAccount
- }
- if account.URL != (accounts.URL{}) && account.URL != w.account.URL {
+ if !w.Contains(account) {
return nil, accounts.ErrUnknownAccount
}
// Account seems valid, request the keystore to sign
@@ -100,10 +97,7 @@ func (w *keystoreWallet) SignHash(account accounts.Account, hash []byte) ([]byte
// be able to sign via our shared keystore backend).
func (w *keystoreWallet) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
// Make sure the requested account is contained within
- if account.Address != w.account.Address {
- return nil, accounts.ErrUnknownAccount
- }
- if account.URL != (accounts.URL{}) && account.URL != w.account.URL {
+ if !w.Contains(account) {
return nil, accounts.ErrUnknownAccount
}
// Account seems valid, request the keystore to sign
@@ -114,10 +108,7 @@ func (w *keystoreWallet) SignTx(account accounts.Account, tx *types.Transaction,
// given hash with the given account using passphrase as extra authentication.
func (w *keystoreWallet) SignHashWithPassphrase(account accounts.Account, passphrase string, hash []byte) ([]byte, error) {
// Make sure the requested account is contained within
- if account.Address != w.account.Address {
- return nil, accounts.ErrUnknownAccount
- }
- if account.URL != (accounts.URL{}) && account.URL != w.account.URL {
+ if !w.Contains(account) {
return nil, accounts.ErrUnknownAccount
}
// Account seems valid, request the keystore to sign
@@ -128,10 +119,7 @@ func (w *keystoreWallet) SignHashWithPassphrase(account accounts.Account, passph
// transaction with the given account using passphrase as extra authentication.
func (w *keystoreWallet) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
// Make sure the requested account is contained within
- if account.Address != w.account.Address {
- return nil, accounts.ErrUnknownAccount
- }
- if account.URL != (accounts.URL{}) && account.URL != w.account.URL {
+ if !w.Contains(account) {
return nil, accounts.ErrUnknownAccount
}
// Account seems valid, request the keystore to sign