aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/key_store_passphrase.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-04-03 03:14:25 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-05-12 23:19:39 +0800
commitda9fe951da4005761a014316c46771d628dc058e (patch)
treed5344172ed915b4890d66c3cf3b4181e30589471 /crypto/key_store_passphrase.go
parent6b23094cff77d7e485e0a2ae5698884f63c87ce7 (diff)
downloadgo-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_store_passphrase.go')
-rw-r--r--crypto/key_store_passphrase.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/crypto/key_store_passphrase.go b/crypto/key_store_passphrase.go
index 4cfb1851b..739483d9f 100644
--- a/crypto/key_store_passphrase.go
+++ b/crypto/key_store_passphrase.go
@@ -68,7 +68,6 @@ import (
"bytes"
"crypto/aes"
"crypto/cipher"
- "encoding/hex"
"encoding/json"
"errors"
"io"
@@ -76,6 +75,7 @@ import (
"path/filepath"
"code.google.com/p/go-uuid/uuid"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/randentropy"
"golang.org/x/crypto/scrypt"
)
@@ -100,7 +100,7 @@ func (ks keyStorePassphrase) GenerateNewKey(rand io.Reader, auth string) (key *K
return GenerateNewKeyDefault(ks, rand, auth)
}
-func (ks keyStorePassphrase) GetKey(keyAddr []byte, auth string) (key *Key, err error) {
+func (ks keyStorePassphrase) GetKey(keyAddr common.Address, auth string) (key *Key, err error) {
keyBytes, keyId, err := DecryptKey(ks, keyAddr, auth)
if err != nil {
return nil, err
@@ -113,7 +113,7 @@ func (ks keyStorePassphrase) GetKey(keyAddr []byte, auth string) (key *Key, err
return key, err
}
-func (ks keyStorePassphrase) GetKeyAddresses() (addresses [][]byte, err error) {
+func (ks keyStorePassphrase) GetKeyAddresses() (addresses []common.Address, err error) {
return GetKeyAddresses(ks.keysDirPath)
}
@@ -150,7 +150,7 @@ func (ks keyStorePassphrase) StoreKey(key *Key, auth string) (err error) {
}
keyStruct := encryptedKeyJSON{
key.Id,
- key.Address,
+ key.Address.Bytes(),
cipherStruct,
}
keyJSON, err := json.Marshal(keyStruct)
@@ -161,18 +161,18 @@ func (ks keyStorePassphrase) StoreKey(key *Key, auth string) (err error) {
return WriteKeyFile(key.Address, ks.keysDirPath, keyJSON)
}
-func (ks keyStorePassphrase) DeleteKey(keyAddr []byte, auth string) (err error) {
+func (ks keyStorePassphrase) DeleteKey(keyAddr common.Address, auth string) (err error) {
// only delete if correct passphrase is given
_, _, err = DecryptKey(ks, keyAddr, auth)
if err != nil {
return err
}
- keyDirPath := filepath.Join(ks.keysDirPath, hex.EncodeToString(keyAddr))
+ keyDirPath := filepath.Join(ks.keysDirPath, keyAddr.Hex())
return os.RemoveAll(keyDirPath)
}
-func DecryptKey(ks keyStorePassphrase, keyAddr []byte, auth string) (keyBytes []byte, keyId []byte, err error) {
+func DecryptKey(ks keyStorePassphrase, keyAddr common.Address, auth string) (keyBytes []byte, keyId []byte, err error) {
fileContent, err := GetKeyFile(ks.keysDirPath, keyAddr)
if err != nil {
return nil, nil, err