aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-28 19:18:41 +0800
committerobscuren <geffobscura@gmail.com>2014-02-28 19:18:41 +0800
commitc0fcefa3a023c643040b3d9e300980bd32c33dff (patch)
tree239b7fc192b42aeb26b7e5e41fefa2e2c1cf2595 /ethutil
parentc9f3d1c00ba70016be4bb871f9ecd50d456c6985 (diff)
downloadgo-tangerine-c0fcefa3a023c643040b3d9e300980bd32c33dff.tar
go-tangerine-c0fcefa3a023c643040b3d9e300980bd32c33dff.tar.gz
go-tangerine-c0fcefa3a023c643040b3d9e300980bd32c33dff.tar.bz2
go-tangerine-c0fcefa3a023c643040b3d9e300980bd32c33dff.tar.lz
go-tangerine-c0fcefa3a023c643040b3d9e300980bd32c33dff.tar.xz
go-tangerine-c0fcefa3a023c643040b3d9e300980bd32c33dff.tar.zst
go-tangerine-c0fcefa3a023c643040b3d9e300980bd32c33dff.zip
Added a GetKeys method to support multiple accounts
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/db.go1
-rw-r--r--ethutil/key.go19
2 files changed, 20 insertions, 0 deletions
diff --git a/ethutil/db.go b/ethutil/db.go
index b11d5d726..abbf4a2b0 100644
--- a/ethutil/db.go
+++ b/ethutil/db.go
@@ -4,6 +4,7 @@ package ethutil
type Database interface {
Put(key []byte, value []byte)
Get(key []byte) ([]byte, error)
+ GetKeys() []*Key
Delete(key []byte) error
LastKnownTD() []byte
Close()
diff --git a/ethutil/key.go b/ethutil/key.go
new file mode 100644
index 000000000..ec195f213
--- /dev/null
+++ b/ethutil/key.go
@@ -0,0 +1,19 @@
+package ethutil
+
+type Key struct {
+ PrivateKey []byte
+ PublicKey []byte
+}
+
+func NewKeyFromBytes(data []byte) *Key {
+ val := NewValueFromBytes(data)
+ return &Key{val.Get(0).Bytes(), val.Get(1).Bytes()}
+}
+
+func (k *Key) Address() []byte {
+ return Sha3Bin(k.PublicKey[1:])[12:]
+}
+
+func (k *Key) RlpEncode() []byte {
+ return EmptyValue().Append(k.PrivateKey).Append(k.PublicKey).Encode()
+}