aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
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 /ethchain
parent0512113bdd5cc55ae35abd442b668ab5ed7a116b (diff)
downloadgo-tangerine-f4fa0d48cb10f925908062357be965c54370cba9.tar
go-tangerine-f4fa0d48cb10f925908062357be965c54370cba9.tar.gz
go-tangerine-f4fa0d48cb10f925908062357be965c54370cba9.tar.bz2
go-tangerine-f4fa0d48cb10f925908062357be965c54370cba9.tar.lz
go-tangerine-f4fa0d48cb10f925908062357be965c54370cba9.tar.xz
go-tangerine-f4fa0d48cb10f925908062357be965c54370cba9.tar.zst
go-tangerine-f4fa0d48cb10f925908062357be965c54370cba9.zip
Moved keyring to ethutil & removed old methods. Implements #20
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/keypair.go87
1 files changed, 0 insertions, 87 deletions
diff --git a/ethchain/keypair.go b/ethchain/keypair.go
deleted file mode 100644
index 0f23bacdf..000000000
--- a/ethchain/keypair.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package ethchain
-
-import (
- "github.com/ethereum/eth-go/ethutil"
- "github.com/obscuren/secp256k1-go"
- "math/big"
-)
-
-type KeyPair struct {
- PrivateKey []byte
- PublicKey []byte
-
- // The associated account
- account *StateObject
- state *State
-}
-
-func NewKeyPairFromSec(seckey []byte) (*KeyPair, error) {
- pubkey, err := secp256k1.GeneratePubKey(seckey)
- if err != nil {
- return nil, err
- }
-
- return &KeyPair{PrivateKey: seckey, PublicKey: pubkey}, nil
-}
-
-func NewKeyPairFromValue(val *ethutil.Value) *KeyPair {
- keyPair := &KeyPair{PrivateKey: val.Get(0).Bytes(), PublicKey: val.Get(1).Bytes()}
-
- return keyPair
-}
-
-func (k *KeyPair) Address() []byte {
- return ethutil.Sha3Bin(k.PublicKey[1:])[12:]
-}
-
-func (k *KeyPair) Account() *StateObject {
- if k.account == nil {
- k.account = k.state.GetAccount(k.Address())
- }
-
- return k.account
-}
-
-// Create transaction, creates a new and signed transaction, ready for processing
-func (k *KeyPair) CreateTx(receiver []byte, value *big.Int, data []string) *Transaction {
- /* TODO
- tx := NewTransaction(receiver, value, data)
- tx.Nonce = k.account.Nonce
-
- // Sign the transaction with the private key in this key chain
- tx.Sign(k.PrivateKey)
-
- return tx
- */
- return nil
-}
-
-func (k *KeyPair) RlpEncode() []byte {
- return ethutil.EmptyValue().Append(k.PrivateKey).Append(k.PublicKey).Encode()
-}
-
-type KeyRing struct {
- keys []*KeyPair
-}
-
-func (k *KeyRing) Add(pair *KeyPair) {
- k.keys = append(k.keys, pair)
-}
-
-// The public "singleton" keyring
-var keyRing *KeyRing
-
-func GetKeyRing(state *State) *KeyRing {
- if keyRing == nil {
- keyRing = &KeyRing{}
-
- data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
- it := ethutil.NewValueFromBytes(data).NewIterator()
- for it.Next() {
- v := it.Value()
- keyRing.Add(NewKeyPairFromValue(v))
- }
- }
-
- return keyRing
-}