diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-02-17 05:28:11 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-02-24 22:27:32 +0800 |
commit | cda91ee18006ee0d012d905385c30485eab8be12 (patch) | |
tree | 00c1edfd4c5fc8feaae132aa0b2d005dd3127dd5 /crypto/key_store_plain.go | |
parent | 66b148dd8f4895dbdedda36030e2ef0c994bea40 (diff) | |
download | go-tangerine-cda91ee18006ee0d012d905385c30485eab8be12.tar go-tangerine-cda91ee18006ee0d012d905385c30485eab8be12.tar.gz go-tangerine-cda91ee18006ee0d012d905385c30485eab8be12.tar.bz2 go-tangerine-cda91ee18006ee0d012d905385c30485eab8be12.tar.lz go-tangerine-cda91ee18006ee0d012d905385c30485eab8be12.tar.xz go-tangerine-cda91ee18006ee0d012d905385c30485eab8be12.tar.zst go-tangerine-cda91ee18006ee0d012d905385c30485eab8be12.zip |
crypto: expose key decryption method to parse a string direclty
Diffstat (limited to 'crypto/key_store_plain.go')
-rw-r--r-- | crypto/key_store_plain.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/crypto/key_store_plain.go b/crypto/key_store_plain.go index c1c23f8b8..4ce789a30 100644 --- a/crypto/key_store_plain.go +++ b/crypto/key_store_plain.go @@ -62,18 +62,16 @@ func GenerateNewKeyDefault(ks KeyStore, rand io.Reader, auth string) (key *Key, return key, err } -func (ks keyStorePlain) GetKey(keyAddr common.Address, auth string) (key *Key, err error) { - key = new(Key) - err = getKey(ks.keysDirPath, keyAddr, key) - return -} - -func getKey(keysDirPath string, keyAddr common.Address, content interface{}) (err error) { - fileContent, err := getKeyFile(keysDirPath, keyAddr) +func (ks keyStorePlain) GetKey(keyAddr common.Address, auth string) (*Key, error) { + keyjson, err := getKeyFile(ks.keysDirPath, keyAddr) if err != nil { - return + return nil, err + } + key := new(Key) + if err := json.Unmarshal(keyjson, key); err != nil { + return nil, err } - return json.Unmarshal(fileContent, content) + return key, nil } func (ks keyStorePlain) GetKeyAddresses() (addresses []common.Address, err error) { |