aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/key_store_plain.go
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/key_store_plain.go')
-rw-r--r--crypto/key_store_plain.go18
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) {