aboutsummaryrefslogtreecommitdiffstats
path: root/accounts
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-10 22:41:08 +0800
committerFelix Lange <fjl@twurst.com>2015-03-10 22:41:08 +0800
commit4ba7871374fd3af08bfad972509267842db6df99 (patch)
treea4952c203a91510f3bc4678f85fa2a718d33c2d0 /accounts
parent0f67f1e9de856404136dcdce78fc0ab93bab6a84 (diff)
downloaddexon-4ba7871374fd3af08bfad972509267842db6df99.tar
dexon-4ba7871374fd3af08bfad972509267842db6df99.tar.gz
dexon-4ba7871374fd3af08bfad972509267842db6df99.tar.bz2
dexon-4ba7871374fd3af08bfad972509267842db6df99.tar.lz
dexon-4ba7871374fd3af08bfad972509267842db6df99.tar.xz
dexon-4ba7871374fd3af08bfad972509267842db6df99.tar.zst
dexon-4ba7871374fd3af08bfad972509267842db6df99.zip
accounts: return ErrNoKeys if key directory does not exist
Diffstat (limited to 'accounts')
-rw-r--r--accounts/account_manager.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/accounts/account_manager.go b/accounts/account_manager.go
index fdd7d83e9..646dc8376 100644
--- a/accounts/account_manager.go
+++ b/accounts/account_manager.go
@@ -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))