From e1b98f49a5075694c5022f5ec74425e40da415dd Mon Sep 17 00:00:00 2001 From: "Peter (bitfly)" <1674920+peterbitfly@users.noreply.github.com> Date: Tue, 28 Feb 2023 14:40:24 +0100 Subject: [PATCH] ethclient: include withdrawals in ethclient block responses (#26778) * include withdrawals in ethclient responses * omit empty withdrawals array in json serialization --- ethclient/ethclient.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 460035f36..6f309030b 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -102,9 +102,10 @@ func (ec *Client) PeerCount(ctx context.Context) (uint64, error) { } type rpcBlock struct { - Hash common.Hash `json:"hash"` - Transactions []rpcTransaction `json:"transactions"` - UncleHashes []common.Hash `json:"uncles"` + Hash common.Hash `json:"hash"` + Transactions []rpcTransaction `json:"transactions"` + UncleHashes []common.Hash `json:"uncles"` + Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` } func (ec *Client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) { @@ -169,7 +170,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface } txs[i] = tx.tx } - return types.NewBlockWithHeader(head).WithBody(txs, uncles), nil + return types.NewBlockWithHeader(head).WithBody(txs, uncles).WithWithdrawals(body.Withdrawals), nil } // HeaderByHash returns the block header with the given hash.