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
49559e6d
Commit
49559e6d
authored
May 11, 2015
by
Daniel A. Nagy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Interactive signature creation refactored into separate doSign function.
parent
a9e1d386
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
xeth.go
xeth/xeth.go
+20
-20
No files found.
xeth/xeth.go
View file @
49559e6d
...
@@ -815,22 +815,30 @@ func (self *XEth) ConfirmTransaction(tx string) bool {
...
@@ -815,22 +815,30 @@ func (self *XEth) ConfirmTransaction(tx string) bool {
return
self
.
frontend
.
ConfirmTransaction
(
tx
)
return
self
.
frontend
.
ConfirmTransaction
(
tx
)
}
}
func
(
self
*
XEth
)
Sign
(
fromStr
,
hashStr
string
,
didUnlock
bool
)
(
string
,
error
)
{
func
(
self
*
XEth
)
doSign
(
from
common
.
Address
,
hash
[]
byte
,
didUnlock
bool
)
([]
byte
,
error
)
{
var
(
sig
,
err
:=
self
.
backend
.
AccountManager
()
.
Sign
(
accounts
.
Account
{
Address
:
from
.
Bytes
()},
hash
)
from
=
common
.
HexToAddress
(
fromStr
)
hash
=
common
.
HexToHash
(
hashStr
)
)
sig
,
err
:=
self
.
backend
.
AccountManager
()
.
Sign
(
accounts
.
Account
{
Address
:
from
.
Bytes
()},
hash
.
Bytes
())
if
err
==
accounts
.
ErrLocked
{
if
err
==
accounts
.
ErrLocked
{
if
didUnlock
{
if
didUnlock
{
return
""
,
fmt
.
Errorf
(
"signer account still locked after successful unlock"
)
return
nil
,
fmt
.
Errorf
(
"signer account still locked after successful unlock"
)
}
}
if
!
self
.
frontend
.
UnlockAccount
(
from
.
Bytes
())
{
if
!
self
.
frontend
.
UnlockAccount
(
from
.
Bytes
())
{
return
""
,
fmt
.
Errorf
(
"could not unlock signer account"
)
return
nil
,
fmt
.
Errorf
(
"could not unlock signer account"
)
}
}
// retry signing, the account should now be unlocked.
// retry signing, the account should now be unlocked.
return
self
.
Sign
(
fromStr
,
hashStr
,
true
)
return
self
.
doSign
(
from
,
hash
,
true
)
}
else
if
err
!=
nil
{
}
else
if
err
!=
nil
{
return
nil
,
err
}
return
sig
,
nil
}
func
(
self
*
XEth
)
Sign
(
fromStr
,
hashStr
string
,
didUnlock
bool
)
(
string
,
error
)
{
var
(
from
=
common
.
HexToAddress
(
fromStr
)
hash
=
common
.
HexToHash
(
hashStr
)
)
sig
,
err
:=
self
.
doSign
(
from
,
hash
.
Bytes
(),
didUnlock
)
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
return
common
.
ToHex
(
sig
),
nil
return
common
.
ToHex
(
sig
),
nil
...
@@ -928,17 +936,9 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
...
@@ -928,17 +936,9 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
}
}
func
(
self
*
XEth
)
sign
(
tx
*
types
.
Transaction
,
from
common
.
Address
,
didUnlock
bool
)
error
{
func
(
self
*
XEth
)
sign
(
tx
*
types
.
Transaction
,
from
common
.
Address
,
didUnlock
bool
)
error
{
sig
,
err
:=
self
.
backend
.
AccountManager
()
.
Sign
(
accounts
.
Account
{
Address
:
from
.
Bytes
()},
tx
.
Hash
()
.
Bytes
())
hash
:=
tx
.
Hash
()
.
Bytes
()
if
err
==
accounts
.
ErrLocked
{
sig
,
err
:=
self
.
doSign
(
from
,
hash
,
didUnlock
)
if
didUnlock
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"sender account still locked after successful unlock"
)
}
if
!
self
.
frontend
.
UnlockAccount
(
from
.
Bytes
())
{
return
fmt
.
Errorf
(
"could not unlock sender account"
)
}
// retry signing, the account should now be unlocked.
return
self
.
sign
(
tx
,
from
,
true
)
}
else
if
err
!=
nil
{
return
err
return
err
}
}
tx
.
SetSignatureValues
(
sig
)
tx
.
SetSignatureValues
(
sig
)
...
...
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