From b6b1c4b7793e58d5730c31af537542ef465b003f Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Mon, 5 Jan 2026 18:12:23 +0800 Subject: [PATCH] internal/ethapi: fix recover sender of pending transaction #23765 (#1898) --- internal/ethapi/api.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index bc3f9893c6..710b4ee18a 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1680,7 +1680,7 @@ type RPCTransaction struct { // newRPCTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int, config *params.ChainConfig) *RPCTransaction { - signer := types.MakeSigner(config, big.NewInt(0).SetUint64(blockNumber)) + signer := types.MakeSigner(config, new(big.Int).SetUint64(blockNumber)) from, _ := types.Sender(signer, tx) v, r, s := tx.RawSignatureValues() result := &RPCTransaction{ @@ -1765,11 +1765,15 @@ func effectiveGasPrice(tx *types.Transaction, baseFee *big.Int) *big.Int { // newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation func newRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction { - var baseFee *big.Int + var ( + baseFee *big.Int + blockNumber = uint64(0) + ) if current != nil { baseFee = eip1559.CalcBaseFee(config, current) + blockNumber = current.Number.Uint64() } - return newRPCTransaction(tx, common.Hash{}, 0, 0, baseFee, config) + return newRPCTransaction(tx, common.Hash{}, blockNumber, 0, baseFee, config) } // newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.