diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-04-03 03:14:25 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-05-12 23:19:39 +0800 |
commit | da9fe951da4005761a014316c46771d628dc058e (patch) | |
tree | d5344172ed915b4890d66c3cf3b4181e30589471 /crypto/key.go | |
parent | 6b23094cff77d7e485e0a2ae5698884f63c87ce7 (diff) | |
download | go-tangerine-da9fe951da4005761a014316c46771d628dc058e.tar go-tangerine-da9fe951da4005761a014316c46771d628dc058e.tar.gz go-tangerine-da9fe951da4005761a014316c46771d628dc058e.tar.bz2 go-tangerine-da9fe951da4005761a014316c46771d628dc058e.tar.lz go-tangerine-da9fe951da4005761a014316c46771d628dc058e.tar.xz go-tangerine-da9fe951da4005761a014316c46771d628dc058e.tar.zst go-tangerine-da9fe951da4005761a014316c46771d628dc058e.zip |
Use common.Address type for accounts.Address
Diffstat (limited to 'crypto/key.go')
-rw-r--r-- | crypto/key.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/key.go b/crypto/key.go index 654d9e83d..5e1f3637e 100644 --- a/crypto/key.go +++ b/crypto/key.go @@ -30,12 +30,13 @@ import ( "io" "code.google.com/p/go-uuid/uuid" + "github.com/ethereum/go-ethereum/common" ) type Key struct { Id uuid.UUID // Version 4 "random" for unique id not derived from key data // to simplify lookups we also store the address - Address []byte + Address common.Address // we only store privkey as pubkey/address can be derived from it // privkey in this struct is always in plaintext PrivateKey *ecdsa.PrivateKey @@ -63,7 +64,7 @@ type encryptedKeyJSON struct { func (k *Key) MarshalJSON() (j []byte, err error) { jStruct := plainKeyJSON{ k.Id, - k.Address, + k.Address.Bytes(), FromECDSA(k.PrivateKey), } j, err = json.Marshal(jStruct) @@ -80,7 +81,7 @@ func (k *Key) UnmarshalJSON(j []byte) (err error) { u := new(uuid.UUID) *u = keyJSON.Id k.Id = *u - k.Address = keyJSON.Address + k.Address = common.BytesToAddress(keyJSON.Address) k.PrivateKey = ToECDSA(keyJSON.PrivateKey) return err @@ -90,7 +91,7 @@ func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key { id := uuid.NewRandom() key := &Key{ Id: id, - Address: PubkeyToAddress(privateKeyECDSA.PublicKey), + Address: common.BytesToAddress(PubkeyToAddress(privateKeyECDSA.PublicKey)), PrivateKey: privateKeyECDSA, } return key |