good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
6f806293
Commit
6f806293
authored
5 years ago
by
Marius van der Wijden
Committed by
Guillaume Ballet
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
accounts: added transactorFromKeyStore (#19685)
parent
afb9e651
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
accounts/abi/bind/auth.go
+19
-0
19 additions, 0 deletions
accounts/abi/bind/auth.go
with
19 additions
and
0 deletions
accounts/abi/bind/auth.go
+
19
−
0
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
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment