Implement eth_accounts (#100)
This commit is contained in:
parent
1b5c33cf33
commit
02047bf8bf
@ -5,6 +5,7 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
|
emintkeys "github.com/cosmos/ethermint/keys"
|
||||||
"github.com/cosmos/ethermint/version"
|
"github.com/cosmos/ethermint/version"
|
||||||
"github.com/cosmos/ethermint/x/evm/types"
|
"github.com/cosmos/ethermint/x/evm/types"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
@ -58,8 +59,24 @@ func (e *PublicEthAPI) GasPrice() *hexutil.Big {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Accounts returns the list of accounts available to this node.
|
// Accounts returns the list of accounts available to this node.
|
||||||
func (e *PublicEthAPI) Accounts() []common.Address {
|
func (e *PublicEthAPI) Accounts() ([]common.Address, error) {
|
||||||
return nil
|
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.
|
// BlockNumber returns the current block number.
|
||||||
|
Loading…
Reference in New Issue
Block a user