Skip to content

Commit e1b98f4

Browse files
authored
ethclient: include withdrawals in ethclient block responses (#26778)
* include withdrawals in ethclient responses * omit empty withdrawals array in json serialization
1 parent 2bb622c commit e1b98f4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ethclient/ethclient.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ func (ec *Client) PeerCount(ctx context.Context) (uint64, error) {
102102
}
103103

104104
type rpcBlock struct {
105-
Hash common.Hash `json:"hash"`
106-
Transactions []rpcTransaction `json:"transactions"`
107-
UncleHashes []common.Hash `json:"uncles"`
105+
Hash common.Hash `json:"hash"`
106+
Transactions []rpcTransaction `json:"transactions"`
107+
UncleHashes []common.Hash `json:"uncles"`
108+
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"`
108109
}
109110

110111
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
169170
}
170171
txs[i] = tx.tx
171172
}
172-
return types.NewBlockWithHeader(head).WithBody(txs, uncles), nil
173+
return types.NewBlockWithHeader(head).WithBody(txs, uncles).WithWithdrawals(body.Withdrawals), nil
173174
}
174175

175176
// HeaderByHash returns the block header with the given hash.

0 commit comments

Comments
 (0)