package hmyapi import ( "github.com/ethereum/go-ethereum/common" "github.com/harmony-one/harmony/accounts" ) // PublicAccountAPI provides an API to access accounts managed by this node. // It offers only methods that can retrieve accounts. type PublicAccountAPI struct { am *accounts.Manager } // NewPublicAccountAPI creates a new PublicAccountAPI. func NewPublicAccountAPI(am *accounts.Manager) *PublicAccountAPI { return &PublicAccountAPI{am: am} } // Accounts returns the collection of accounts this node manages func (s *PublicAccountAPI) Accounts() []common.Address { addresses := make([]common.Address, 0) // return [] instead of nil if empty for _, wallet := range s.am.Wallets() { for _, account := range wallet.Accounts() { addresses = append(addresses, account.Address) } } return addresses }