Commit 4ba78713 authored by Felix Lange's avatar Felix Lange

accounts: return ErrNoKeys if key directory does not exist

parent 0f67f1e9
...@@ -36,6 +36,7 @@ import ( ...@@ -36,6 +36,7 @@ import (
"bytes" "bytes"
"crypto/ecdsa" "crypto/ecdsa"
crand "crypto/rand" crand "crypto/rand"
"os"
"errors" "errors"
"sync" "sync"
...@@ -89,7 +90,9 @@ func (am *Manager) Coinbase() (addr []byte, err error) { ...@@ -89,7 +90,9 @@ func (am *Manager) Coinbase() (addr []byte, err error) {
func (am *Manager) firstAddr() ([]byte, error) { func (am *Manager) firstAddr() ([]byte, error) {
addrs, err := am.keyStore.GetKeyAddresses() addrs, err := am.keyStore.GetKeyAddresses()
if err != nil { if os.IsNotExist(err) {
return nil, ErrNoKeys
} else if err != nil {
return nil, err return nil, err
} }
if len(addrs) == 0 { if len(addrs) == 0 {
...@@ -147,7 +150,9 @@ func (am *Manager) NewAccount(auth string) (Account, error) { ...@@ -147,7 +150,9 @@ func (am *Manager) NewAccount(auth string) (Account, error) {
func (am *Manager) Accounts() ([]Account, error) { func (am *Manager) Accounts() ([]Account, error) {
addresses, err := am.keyStore.GetKeyAddresses() addresses, err := am.keyStore.GetKeyAddresses()
if err != nil { if os.IsNotExist(err) {
return nil, ErrNoKeys
} else if err != nil {
return nil, err return nil, err
} }
accounts := make([]Account, len(addresses)) accounts := make([]Account, len(addresses))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment