19
19
package geth
20
20
21
21
import (
22
- "errors"
23
22
"math/big"
24
23
"strings"
25
24
@@ -28,7 +27,6 @@ import (
28
27
"github.com/ethereum/go-ethereum/accounts/keystore"
29
28
"github.com/ethereum/go-ethereum/common"
30
29
"github.com/ethereum/go-ethereum/core/types"
31
- "github.com/ethereum/go-ethereum/crypto"
32
30
)
33
31
34
32
// Signer is an interface defining the callback when a contract requires a
@@ -82,28 +80,14 @@ func NewTransactOpts() *TransactOpts {
82
80
return new (TransactOpts )
83
81
}
84
82
85
- // NewKeyedTransactor is a utility method to easily create a transaction signer
83
+ // NewKeyedTransactOpts is a utility method to easily create a transaction signer
86
84
// from a single private key.
87
85
func NewKeyedTransactOpts (keyJson []byte , passphrase string ) (* TransactOpts , error ) {
88
86
key , err := keystore .DecryptKey (keyJson , passphrase )
89
87
if err != nil {
90
88
return nil , err
91
89
}
92
- keyAddr := crypto .PubkeyToAddress (key .PrivateKey .PublicKey )
93
- opts := bind.TransactOpts {
94
- From : keyAddr ,
95
- Signer : func (signer types.Signer , address common.Address , tx * types.Transaction ) (* types.Transaction , error ) {
96
- if address != keyAddr {
97
- return nil , errors .New ("not authorized to sign this account" )
98
- }
99
- signature , err := crypto .Sign (signer .Hash (tx ).Bytes (), key .PrivateKey )
100
- if err != nil {
101
- return nil , err
102
- }
103
- return tx .WithSignature (signer , signature )
104
- },
105
- }
106
- return & TransactOpts {opts }, nil
90
+ return & TransactOpts {* bind .NewKeyedTransactor (key .PrivateKey )}, nil
107
91
}
108
92
109
93
func (opts * TransactOpts ) GetFrom () * Address { return & Address {opts .opts .From } }
0 commit comments