accounts: return ErrNoKeys if key directory does not exist

This commit is contained in:
Felix Lange 2015-03-10 15:41:08 +01:00
parent 0f67f1e9de
commit 4ba7871374

View File

@ -36,6 +36,7 @@ import (
"bytes"
"crypto/ecdsa"
crand "crypto/rand"
"os"
"errors"
"sync"
@ -89,7 +90,9 @@ func (am *Manager) Coinbase() (addr []byte, err error) {
func (am *Manager) firstAddr() ([]byte, error) {
addrs, err := am.keyStore.GetKeyAddresses()
if err != nil {
if os.IsNotExist(err) {
return nil, ErrNoKeys
} else if err != nil {
return nil, err
}
if len(addrs) == 0 {
@ -147,7 +150,9 @@ func (am *Manager) NewAccount(auth string) (Account, error) {
func (am *Manager) Accounts() ([]Account, error) {
addresses, err := am.keyStore.GetKeyAddresses()
if err != nil {
if os.IsNotExist(err) {
return nil, ErrNoKeys
} else if err != nil {
return nil, err
}
accounts := make([]Account, len(addresses))