diff options
author | Péter Szilágyi <peterke@gmail.com> | 2018-10-10 18:22:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-10 18:22:43 +0800 |
commit | f951e23fb5ad2f7017f314a95287bc0506a67d05 (patch) | |
tree | 219a46a4fbe92aa225043b164d5a811f1c989adb | |
parent | 4e474c74dc2ac1d26b339c32064d0bac98775e77 (diff) | |
parent | aff421e78c4cc40708e6aaf602730d5028995bdd (diff) | |
download | dexon-f951e23fb5ad2f7017f314a95287bc0506a67d05.tar dexon-f951e23fb5ad2f7017f314a95287bc0506a67d05.tar.gz dexon-f951e23fb5ad2f7017f314a95287bc0506a67d05.tar.bz2 dexon-f951e23fb5ad2f7017f314a95287bc0506a67d05.tar.lz dexon-f951e23fb5ad2f7017f314a95287bc0506a67d05.tar.xz dexon-f951e23fb5ad2f7017f314a95287bc0506a67d05.tar.zst dexon-f951e23fb5ad2f7017f314a95287bc0506a67d05.zip |
Merge pull request #17887 from karalabe/warn-failed-account-access
internal/ethapi: warn on failed account accesses
-rw-r--r-- | internal/ethapi/api.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 8016ebe3d..196be43e0 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -328,6 +328,9 @@ func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string, d = time.Duration(*duration) * time.Second } err := fetchKeystore(s.am).TimedUnlock(accounts.Account{Address: addr}, password, d) + if err != nil { + log.Warn("Failed account unlock attempt", "address", addr, "err", err) + } return err == nil, err } @@ -339,7 +342,7 @@ func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool { // signTransactions sets defaults and signs the given transaction // NOTE: the caller needs to ensure that the nonceLock is held, if applicable, // and release it after the transaction has been submitted to the tx pool -func (s *PrivateAccountAPI) signTransaction(ctx context.Context, args SendTxArgs, passwd string) (*types.Transaction, error) { +func (s *PrivateAccountAPI) signTransaction(ctx context.Context, args *SendTxArgs, passwd string) (*types.Transaction, error) { // Look up the wallet containing the requested signer account := accounts.Account{Address: args.From} wallet, err := s.am.Find(account) @@ -370,8 +373,9 @@ func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs s.nonceLock.LockAddr(args.From) defer s.nonceLock.UnlockAddr(args.From) } - signed, err := s.signTransaction(ctx, args, passwd) + signed, err := s.signTransaction(ctx, &args, passwd) if err != nil { + log.Warn("Failed transaction send attempt", "from", args.From, "to", args.To, "value", args.Value.ToInt(), "err", err) return common.Hash{}, err } return submitTransaction(ctx, s.b, signed) @@ -393,8 +397,9 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs if args.Nonce == nil { return nil, fmt.Errorf("nonce not specified") } - signed, err := s.signTransaction(ctx, args, passwd) + signed, err := s.signTransaction(ctx, &args, passwd) if err != nil { + log.Warn("Failed transaction sign attempt", "from", args.From, "to", args.To, "value", args.Value.ToInt(), "err", err) return nil, err } data, err := rlp.EncodeToBytes(signed) @@ -436,6 +441,7 @@ func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr c // Assemble sign the data with the wallet signature, err := wallet.SignHashWithPassphrase(account, passwd, signHash(data)) if err != nil { + log.Warn("Failed data sign attempt", "address", addr, "err", err) return nil, err } signature[64] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper |