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
6f806293
Commit
6f806293
authored
Jun 08, 2019
by
Marius van der Wijden
Committed by
Guillaume Ballet
Jun 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts: added transactorFromKeyStore (#19685)
parent
afb9e651
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
auth.go
accounts/abi/bind/auth.go
+19
-0
No files found.
accounts/abi/bind/auth.go
View file @
6f806293
...
...
@@ -22,6 +22,7 @@ import (
"io"
"io/ioutil"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
...
...
@@ -42,6 +43,24 @@ func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
return
NewKeyedTransactor
(
key
.
PrivateKey
),
nil
}
// NewTransactor is a utility method to easily create a transaction signer from
// an decrypted key from a keystore
func
NewTransactorFromKeyStore
(
keystore
*
keystore
.
KeyStore
,
account
accounts
.
Account
)
(
*
TransactOpts
,
error
)
{
return
&
TransactOpts
{
From
:
account
.
Address
,
Signer
:
func
(
signer
types
.
Signer
,
address
common
.
Address
,
tx
*
types
.
Transaction
)
(
*
types
.
Transaction
,
error
)
{
if
address
!=
account
.
Address
{
return
nil
,
errors
.
New
(
"not authorized to sign this account"
)
}
signature
,
err
:=
keystore
.
SignHash
(
account
,
signer
.
Hash
(
tx
)
.
Bytes
())
if
err
!=
nil
{
return
nil
,
err
}
return
tx
.
WithSignature
(
signer
,
signature
)
},
},
nil
}
// NewKeyedTransactor is a utility method to easily create a transaction signer
// from a single private key.
func
NewKeyedTransactor
(
key
*
ecdsa
.
PrivateKey
)
*
TransactOpts
{
...
...
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