Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
aff421e7
Unverified
Commit
aff421e7
authored
Oct 10, 2018
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/ethapi: warn on failed account accesses
parent
4e474c74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
api.go
internal/ethapi/api.go
+9
-3
No files found.
internal/ethapi/api.go
View file @
aff421e7
...
@@ -328,6 +328,9 @@ func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string,
...
@@ -328,6 +328,9 @@ func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string,
d
=
time
.
Duration
(
*
duration
)
*
time
.
Second
d
=
time
.
Duration
(
*
duration
)
*
time
.
Second
}
}
err
:=
fetchKeystore
(
s
.
am
)
.
TimedUnlock
(
accounts
.
Account
{
Address
:
addr
},
password
,
d
)
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
return
err
==
nil
,
err
}
}
...
@@ -339,7 +342,7 @@ func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool {
...
@@ -339,7 +342,7 @@ func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool {
// signTransactions sets defaults and signs the given transaction
// signTransactions sets defaults and signs the given transaction
// NOTE: the caller needs to ensure that the nonceLock is held, if applicable,
// 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
// 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
// Look up the wallet containing the requested signer
account
:=
accounts
.
Account
{
Address
:
args
.
From
}
account
:=
accounts
.
Account
{
Address
:
args
.
From
}
wallet
,
err
:=
s
.
am
.
Find
(
account
)
wallet
,
err
:=
s
.
am
.
Find
(
account
)
...
@@ -370,8 +373,9 @@ func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs
...
@@ -370,8 +373,9 @@ func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs
s
.
nonceLock
.
LockAddr
(
args
.
From
)
s
.
nonceLock
.
LockAddr
(
args
.
From
)
defer
s
.
nonceLock
.
UnlockAddr
(
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
{
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
common
.
Hash
{},
err
}
}
return
submitTransaction
(
ctx
,
s
.
b
,
signed
)
return
submitTransaction
(
ctx
,
s
.
b
,
signed
)
...
@@ -393,8 +397,9 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs
...
@@ -393,8 +397,9 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs
if
args
.
Nonce
==
nil
{
if
args
.
Nonce
==
nil
{
return
nil
,
fmt
.
Errorf
(
"nonce not specified"
)
return
nil
,
fmt
.
Errorf
(
"nonce not specified"
)
}
}
signed
,
err
:=
s
.
signTransaction
(
ctx
,
args
,
passwd
)
signed
,
err
:=
s
.
signTransaction
(
ctx
,
&
args
,
passwd
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warn
(
"Failed transaction sign attempt"
,
"from"
,
args
.
From
,
"to"
,
args
.
To
,
"value"
,
args
.
Value
.
ToInt
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
data
,
err
:=
rlp
.
EncodeToBytes
(
signed
)
data
,
err
:=
rlp
.
EncodeToBytes
(
signed
)
...
@@ -436,6 +441,7 @@ func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr c
...
@@ -436,6 +441,7 @@ func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr c
// Assemble sign the data with the wallet
// Assemble sign the data with the wallet
signature
,
err
:=
wallet
.
SignHashWithPassphrase
(
account
,
passwd
,
signHash
(
data
))
signature
,
err
:=
wallet
.
SignHashWithPassphrase
(
account
,
passwd
,
signHash
(
data
))
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warn
(
"Failed data sign attempt"
,
"address"
,
addr
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
signature
[
64
]
+=
27
// Transform V from 0/1 to 27/28 according to the yellow paper
signature
[
64
]
+=
27
// Transform V from 0/1 to 27/28 according to the yellow paper
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment