internal/ethapi: fix encoding of uncle headers and pending blocks #20460 (#1599)

This commit is contained in:
Daniel Liu 2025-10-08 12:56:31 +08:00 committed by GitHub
parent e48bda95c3
commit 72bfc81606
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}