aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/bind/auth.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-03-02 20:57:15 +0800
committerFelix Lange <fjl@twurst.com>2016-04-12 21:56:49 +0800
commit85e6c40c0081bd0db80448640db648887804010c (patch)
tree326a2c3bc115a445b481624cb20f00b28e44f92a /accounts/abi/bind/auth.go
parentdff9b4246f3ef9e6c254b57eef6d0433809f16b9 (diff)
downloadgo-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.gz
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.bz2
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.lz
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.xz
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.tar.zst
go-tangerine-85e6c40c0081bd0db80448640db648887804010c.zip
accounts, crypto: move keystore to package accounts
The account management API was originally implemented as a thin layer around crypto.KeyStore, on the grounds that several kinds of key stores would be implemented later on. It turns out that this won't happen so KeyStore is a superflous abstraction. In this commit crypto.KeyStore and everything related to it moves to package accounts and is unexported.
Diffstat (limited to 'accounts/abi/bind/auth.go')
-rw-r--r--accounts/abi/bind/auth.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/accounts/abi/bind/auth.go b/accounts/abi/bind/auth.go
index 624f995b0..2cf22768c 100644
--- a/accounts/abi/bind/auth.go
+++ b/accounts/abi/bind/auth.go
@@ -17,10 +17,12 @@
package bind
import (
+ "crypto/ecdsa"
"errors"
"io"
"io/ioutil"
+ "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
@@ -33,23 +35,24 @@ func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
if err != nil {
return nil, err
}
- key, err := crypto.DecryptKey(json, passphrase)
+ key, err := accounts.DecryptKey(json, passphrase)
if err != nil {
return nil, err
}
- return NewKeyedTransactor(key), nil
+ return NewKeyedTransactor(key.PrivateKey), nil
}
// NewKeyedTransactor is a utility method to easily create a transaction signer
-// from a plain go-ethereum crypto key.
-func NewKeyedTransactor(key *crypto.Key) *TransactOpts {
+// from a single private key.
+func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
+ keyAddr := crypto.PubkeyToAddress(key.PublicKey)
return &TransactOpts{
- From: key.Address,
+ From: keyAddr,
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
- if address != key.Address {
+ if address != keyAddr {
return nil, errors.New("not authorized to sign this account")
}
- signature, err := crypto.Sign(tx.SigHash().Bytes(), key.PrivateKey)
+ signature, err := crypto.Sign(tx.SigHash().Bytes(), key)
if err != nil {
return nil, err
}