@@ -1443,7 +1443,7 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
1443
1443
// RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
1444
1444
// returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain
1445
1445
// transaction hashes.
1446
- func RPCMarshalBlock (block * types.Block , inclTx bool , fullTx bool ) (map [string ]interface {}, error ) {
1446
+ func RPCMarshalBlock (block * types.Block , inclTx bool , fullTx bool , config * params. ChainConfig ) (map [string ]interface {}, error ) {
1447
1447
fields := RPCMarshalHeader (block .Header ())
1448
1448
fields ["size" ] = hexutil .Uint64 (block .Size ())
1449
1449
@@ -1453,7 +1453,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool) (map[string]i
1453
1453
}
1454
1454
if fullTx {
1455
1455
formatTx = func (tx * types.Transaction ) (interface {}, error ) {
1456
- return newRPCTransactionFromBlockHash (block , tx .Hash ()), nil
1456
+ return newRPCTransactionFromBlockHash (block , tx .Hash (), config ), nil
1457
1457
}
1458
1458
}
1459
1459
txs := block .Transactions ()
@@ -1478,7 +1478,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool) (map[string]i
1478
1478
// rpcMarshalBlock uses the generalized output filler, then adds the total difficulty field, which requires
1479
1479
// a `BlockChainAPI`.
1480
1480
func (s * BlockChainAPI ) rpcMarshalBlock (b * types.Block , inclTx bool , fullTx bool ) (map [string ]interface {}, error ) {
1481
- fields , err := RPCMarshalBlock (b , inclTx , fullTx )
1481
+ fields , err := RPCMarshalBlock (b , inclTx , fullTx , s . b . ChainConfig () )
1482
1482
if err != nil {
1483
1483
return nil , err
1484
1484
}
@@ -1659,17 +1659,8 @@ type RPCTransaction struct {
1659
1659
1660
1660
// newRPCTransaction returns a transaction that will serialize to the RPC
1661
1661
// representation, with the given location metadata set (if available).
1662
- func newRPCTransaction (tx * types.Transaction , blockHash common.Hash , blockNumber uint64 , index uint64 , baseFee * big.Int ) * RPCTransaction {
1663
- // Determine the signer. For replay-protected transactions, use the most permissive
1664
- // signer, because we assume that signers are backwards-compatible with old
1665
- // transactions. For non-protected transactions, the homestead signer signer is used
1666
- // because the return value of ChainId is zero for those transactions.
1667
- var signer types.Signer
1668
- if tx .Protected () {
1669
- signer = types .LatestSignerForChainID (tx .ChainId ())
1670
- } else {
1671
- signer = types.HomesteadSigner {}
1672
- }
1662
+ func newRPCTransaction (tx * types.Transaction , blockHash common.Hash , blockNumber uint64 , index uint64 , baseFee * big.Int , config * params.ChainConfig ) * RPCTransaction {
1663
+ signer := types .MakeSigner (config , big .NewInt (0 ).SetUint64 (blockNumber ))
1673
1664
from , _ := types .Sender (signer , tx )
1674
1665
v , r , s := tx .RawSignatureValues ()
1675
1666
result := & RPCTransaction {
@@ -1724,16 +1715,16 @@ func newRPCPendingTransaction(tx *types.Transaction, current *types.Header, conf
1724
1715
if current != nil {
1725
1716
baseFee = eip1559 .CalcBaseFee (config , current )
1726
1717
}
1727
- return newRPCTransaction (tx , common.Hash {}, 0 , 0 , baseFee )
1718
+ return newRPCTransaction (tx , common.Hash {}, 0 , 0 , baseFee , config )
1728
1719
}
1729
1720
1730
1721
// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.
1731
- func newRPCTransactionFromBlockIndex (b * types.Block , index uint64 ) * RPCTransaction {
1722
+ func newRPCTransactionFromBlockIndex (b * types.Block , index uint64 , config * params. ChainConfig ) * RPCTransaction {
1732
1723
txs := b .Transactions ()
1733
1724
if index >= uint64 (len (txs )) {
1734
1725
return nil
1735
1726
}
1736
- return newRPCTransaction (txs [index ], b .Hash (), b .NumberU64 (), index , b .BaseFee ())
1727
+ return newRPCTransaction (txs [index ], b .Hash (), b .NumberU64 (), index , b .BaseFee (), config )
1737
1728
}
1738
1729
1739
1730
// newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index.
@@ -1747,10 +1738,10 @@ func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.By
1747
1738
}
1748
1739
1749
1740
// newRPCTransactionFromBlockHash returns a transaction that will serialize to the RPC representation.
1750
- func newRPCTransactionFromBlockHash (b * types.Block , hash common.Hash ) * RPCTransaction {
1741
+ func newRPCTransactionFromBlockHash (b * types.Block , hash common.Hash , config * params. ChainConfig ) * RPCTransaction {
1751
1742
for idx , tx := range b .Transactions () {
1752
1743
if tx .Hash () == hash {
1753
- return newRPCTransactionFromBlockIndex (b , uint64 (idx ))
1744
+ return newRPCTransactionFromBlockIndex (b , uint64 (idx ), config )
1754
1745
}
1755
1746
}
1756
1747
return nil
@@ -1911,15 +1902,15 @@ func (s *TransactionAPI) GetBlockTransactionCountByHash(ctx context.Context, blo
1911
1902
// GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.
1912
1903
func (s * TransactionAPI ) GetTransactionByBlockNumberAndIndex (ctx context.Context , blockNr rpc.BlockNumber , index hexutil.Uint ) * RPCTransaction {
1913
1904
if block , _ := s .b .BlockByNumber (ctx , blockNr ); block != nil {
1914
- return newRPCTransactionFromBlockIndex (block , uint64 (index ))
1905
+ return newRPCTransactionFromBlockIndex (block , uint64 (index ), s . b . ChainConfig () )
1915
1906
}
1916
1907
return nil
1917
1908
}
1918
1909
1919
1910
// GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.
1920
1911
func (s * TransactionAPI ) GetTransactionByBlockHashAndIndex (ctx context.Context , blockHash common.Hash , index hexutil.Uint ) * RPCTransaction {
1921
1912
if block , _ := s .b .GetBlock (ctx , blockHash ); block != nil {
1922
- return newRPCTransactionFromBlockIndex (block , uint64 (index ))
1913
+ return newRPCTransactionFromBlockIndex (block , uint64 (index ), s . b . ChainConfig () )
1923
1914
}
1924
1915
return nil
1925
1916
}
@@ -1968,7 +1959,7 @@ func (s *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.H
1968
1959
if err != nil {
1969
1960
return nil , err
1970
1961
}
1971
- return newRPCTransaction (tx , blockHash , blockNumber , index , header .BaseFee ), nil
1962
+ return newRPCTransaction (tx , blockHash , blockNumber , index , header .BaseFee , s . b . ChainConfig () ), nil
1972
1963
}
1973
1964
// No finalized transaction, try to retrieve it from the pool
1974
1965
if tx := s .b .GetPoolTransaction (hash ); tx != nil {
0 commit comments