forked from cerc-io/laconicd-deprecated
rpc: implement eth_coinbase (#325)
* rpc: implement eth_coinbase * changelog * address comments from review * changelog
This commit is contained in:
+3
-1
@@ -47,13 +47,15 @@ func NewEthermintBackend(cliCtx context.CLIContext) *EthermintBackend {
|
||||
|
||||
// BlockNumber returns the current block number.
|
||||
func (e *EthermintBackend) BlockNumber() (hexutil.Uint64, error) {
|
||||
res, _, err := e.cliCtx.QueryWithData(fmt.Sprintf("custom/%s/blockNumber", types.ModuleName), nil)
|
||||
res, height, err := e.cliCtx.QueryWithData(fmt.Sprintf("custom/%s/blockNumber", types.ModuleName), nil)
|
||||
if err != nil {
|
||||
return hexutil.Uint64(0), err
|
||||
}
|
||||
|
||||
var out types.QueryResBlockNumber
|
||||
e.cliCtx.Codec.MustUnmarshalJSON(res, &out)
|
||||
|
||||
e.cliCtx.WithHeight(height)
|
||||
return hexutil.Uint64(out.Number), nil
|
||||
}
|
||||
|
||||
|
||||
+13
-3
@@ -90,9 +90,19 @@ func (e *PublicEthAPI) Syncing() (interface{}, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Coinbase returns this node's coinbase address. Not used in Ethermint.
|
||||
func (e *PublicEthAPI) Coinbase() (addr common.Address) {
|
||||
return
|
||||
// Coinbase is the address that staking rewards will be send to (alias for Etherbase).
|
||||
func (e *PublicEthAPI) Coinbase() (common.Address, error) {
|
||||
node, err := e.cliCtx.GetNode()
|
||||
if err != nil {
|
||||
return common.Address{}, err
|
||||
}
|
||||
|
||||
status, err := node.Status()
|
||||
if err != nil {
|
||||
return common.Address{}, err
|
||||
}
|
||||
|
||||
return common.BytesToAddress(status.ValidatorInfo.Address.Bytes()), nil
|
||||
}
|
||||
|
||||
// Mining returns whether or not this node is currently mining. Always false.
|
||||
|
||||
Reference in New Issue
Block a user