Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions rpc/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"

"github.com/cosmos/cosmos-sdk/client/context"
emintkeys "github.com/cosmos/ethermint/keys"
"github.com/cosmos/ethermint/version"
"github.com/cosmos/ethermint/x/evm/types"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -58,8 +59,24 @@ func (e *PublicEthAPI) GasPrice() *hexutil.Big {
}

// Accounts returns the list of accounts available to this node.
func (e *PublicEthAPI) Accounts() []common.Address {
return nil
func (e *PublicEthAPI) Accounts() ([]common.Address, error) {
addresses := make([]common.Address, 0) // return [] instead of nil if empty
keybase, err := emintkeys.NewKeyBaseFromHomeFlag()
if err != nil {
return addresses, err
}

infos, err := keybase.List()
if err != nil {
return addresses, err
}

for _, info := range infos {
addressBytes := info.GetPubKey().Address().Bytes()
addresses = append(addresses, common.BytesToAddress(addressBytes))
}

return addresses, nil
}

// BlockNumber returns the current block number.
Expand Down