aboutsummaryrefslogtreecommitdiffstats
path: root/ethpub
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-14 19:54:40 +0800
committerobscuren <geffobscura@gmail.com>2014-05-14 19:54:40 +0800
commitf4fa0d48cb10f925908062357be965c54370cba9 (patch)
tree4b274e1a6a25fb6a468d52a2e1e67775b42d0a0f /ethpub
parent0512113bdd5cc55ae35abd442b668ab5ed7a116b (diff)
downloaddexon-f4fa0d48cb10f925908062357be965c54370cba9.tar.gz
dexon-f4fa0d48cb10f925908062357be965c54370cba9.tar.zst
dexon-f4fa0d48cb10f925908062357be965c54370cba9.zip
Moved keyring to ethutil & removed old methods. Implements #20
Diffstat (limited to 'ethpub')
-rw-r--r--ethpub/pub.go13
-rw-r--r--ethpub/types.go2
2 files changed, 6 insertions, 9 deletions
diff --git a/ethpub/pub.go b/ethpub/pub.go
index 4d1536368..daacb9d78 100644
--- a/ethpub/pub.go
+++ b/ethpub/pub.go
@@ -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 {
diff --git a/ethpub/types.go b/ethpub/types.go
index 7f25e48a6..c902afc56 100644
--- a/ethpub/types.go
+++ b/ethpub/types.go
@@ -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)}
}