internal/ethapi: fix recover sender of pending transaction #23765 (#1898)

This commit is contained in:
Daniel Liu 2026-01-05 18:12:23 +08:00 committed by GitHub
parent 51b99e40a8
commit b6b1c4b779
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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