From 72bfc81606b31be0dfce33538f38a301c9912ae7 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Wed, 8 Oct 2025 12:56:31 +0800 Subject: [PATCH] internal/ethapi: fix encoding of uncle headers and pending blocks #20460 (#1599) --- internal/ethapi/api.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 3a7b68e39f..cb1abee061 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -414,7 +414,7 @@ func (s *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNu response, err := s.rpcMarshalBlock(block, true, fullTx) if err == nil && number == rpc.PendingBlockNumber { // Pending blocks need to nil out a few fields - for _, field := range []string{"hash", "nonce", "miner"} { + for _, field := range []string{"hash", "nonce", "miner", "number"} { response[field] = nil } } @@ -1379,7 +1379,9 @@ func (s *BlockChainAPI) rpcMarshalBlock(b *types.Block, inclTx bool, fullTx bool if err != nil { return nil, err } - fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(context.Background(), b.Hash())) + if inclTx { + fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(context.Background(), b.Hash())) + } return fields, err }