diff --git a/client/src/client.rs b/client/src/client.rs index ea9e04f..0f87a82 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -453,4 +453,8 @@ impl Client { pub async fn get_header(&self) -> Result
{ self.node.read().await.get_header() } + + pub async fn get_coinbase(&self) -> Result
{ + self.node.read().await.get_coinbase() + } } diff --git a/client/src/node.rs b/client/src/node.rs index b9308f8..9987413 100644 --- a/client/src/node.rs +++ b/client/src/node.rs @@ -291,6 +291,13 @@ impl Node { Ok(self.consensus.get_header().clone()) } + pub fn get_coinbase(&self) -> Result
{ + self.check_head_age()?; + let payload = self.get_payload(BlockTag::Latest)?; + let coinbase_address = Address::from_slice(&payload.fee_recipient); + Ok(coinbase_address) + } + pub fn get_last_checkpoint(&self) -> Option> { self.consensus.last_checkpoint.clone() } diff --git a/client/src/rpc.rs b/client/src/rpc.rs index 43b867d..8044da2 100644 --- a/client/src/rpc.rs +++ b/client/src/rpc.rs @@ -112,6 +112,8 @@ trait EthRpc { slot: H256, block: BlockTag, ) -> Result; + #[method(name = "getCoinbase")] + async fn get_coinbase(&self) -> Result; } #[rpc(client, server, namespace = "net")] @@ -270,6 +272,12 @@ impl EthRpcServer for RpcInner { .await, ) } + + async fn get_coinbase(&self) -> Result { + let node = self.node.read().await; + Ok(node.get_coinbase().unwrap()) + } + async fn get_logs(&self, filter: Filter) -> Result, Error> { let node = self.node.read().await; convert_err(node.get_logs(&filter).await)