forked from cerc-io/plugeth
Moved keyring to ethutil & removed old methods. Implements #20
This commit is contained in:
+5
-8
@@ -39,10 +39,7 @@ func (lib *PEthereum) GetBlock(hexHash string) *PBlock {
|
||||
}
|
||||
|
||||
func (lib *PEthereum) GetKey() *PKey {
|
||||
keyPair, err := ethchain.NewKeyPairFromSec(ethutil.Config.Db.GetKeys()[0].PrivateKey)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
keyPair := ethutil.GetKeyRing().Get(0)
|
||||
|
||||
return NewPKey(keyPair)
|
||||
}
|
||||
@@ -90,7 +87,7 @@ func (lib *PEthereum) IsContract(address string) bool {
|
||||
}
|
||||
|
||||
func (lib *PEthereum) SecretToAddress(key string) string {
|
||||
pair, err := ethchain.NewKeyPairFromSec(ethutil.FromHex(key))
|
||||
pair, err := ethutil.NewKeyPairFromSec(ethutil.FromHex(key))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
@@ -115,12 +112,12 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in
|
||||
hash = ethutil.FromHex(recipient)
|
||||
}
|
||||
|
||||
var keyPair *ethchain.KeyPair
|
||||
var keyPair *ethutil.KeyPair
|
||||
var err error
|
||||
if key[0:2] == "0x" {
|
||||
keyPair, err = ethchain.NewKeyPairFromSec([]byte(ethutil.FromHex(key[0:2])))
|
||||
keyPair, err = ethutil.NewKeyPairFromSec([]byte(ethutil.FromHex(key[0:2])))
|
||||
} else {
|
||||
keyPair, err = ethchain.NewKeyPairFromSec([]byte(ethutil.FromHex(key)))
|
||||
keyPair, err = ethutil.NewKeyPairFromSec([]byte(ethutil.FromHex(key)))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ type PKey struct {
|
||||
PublicKey string `json:"publicKey"`
|
||||
}
|
||||
|
||||
func NewPKey(key *ethchain.KeyPair) *PKey {
|
||||
func NewPKey(key *ethutil.KeyPair) *PKey {
|
||||
return &PKey{ethutil.Hex(key.Address()), ethutil.Hex(key.PrivateKey), ethutil.Hex(key.PublicKey)}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user