ethapi: bubble up listaccounts error, remove extapi ref from private acct api

This commit is contained in:
Martin Holst Swende 2018-09-25 17:28:46 +02:00
parent 9e3f27fc18
commit b1da7dfece
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
2 changed files with 11 additions and 15 deletions

View file

@ -191,21 +191,17 @@ func NewPrivateAccountAPI(b Backend, nonceLock *AddrLocker) *PrivateAccountAPI {
p := &PrivateAccountAPI{
nonceLock: nonceLock,
b: b,
extapi: b.ExternalSigner(),
}
return p
}
// ListAccounts will return a list of addresses for accounts this node manages.
func (s *PrivateAccountAPI) ListAccounts() []common.Address {
addresses := make([]common.Address, 0) // return [] instead of nil if empty
if s.extapi != nil {
if accounts, err := s.extapi.ListAccounts(); err == nil {
return accounts
func (s *PrivateAccountAPI) ListAccounts() ([]common.Address, error) {
if extapi := s.b.ExternalSigner(); extapi != nil {
return extapi.ListAccounts()
}
return addresses
}
return addresses
// return [] instead of nil if empty
return []common.Address{}, errors.New("external signer not configured")
}
// rawWallet is a JSON representation of an accounts.Wallet interface, with its