diff options
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/manager.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/accounts/manager.go b/accounts/manager.go index 3cf3422e7..731d12ea3 100644 --- a/accounts/manager.go +++ b/accounts/manager.go @@ -21,6 +21,7 @@ import ( "sort" "sync" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/event" ) @@ -162,6 +163,20 @@ func (am *Manager) Wallet(url string) (Wallet, error) { return nil, ErrUnknownWallet } +// Accounts returns all account addresses of all wallets within the account manager +func (am *Manager) Accounts() []common.Address { + am.lock.RLock() + defer am.lock.RUnlock() + + addresses := make([]common.Address, 0) // return [] instead of nil if empty + for _, wallet := range am.wallets { + for _, account := range wallet.Accounts() { + addresses = append(addresses, account.Address) + } + } + return addresses +} + // Find attempts to locate the wallet corresponding to a specific account. Since // accounts can be dynamically added to and removed from wallets, this method has // a linear runtime in the number of wallets. |