Fix for getTransactionReceipt returning empty 'from' address. (#242)

* Fix for getTransactionReceipt returning empty 'from' address.

* Unify the code

* Unify the code
This commit was merged in pull request #242.
This commit is contained in:
2023-06-12 11:37:46 -05:00
committed by GitHub
parent 50b402cfaa
commit 77f861dd95
3 changed files with 11 additions and 11 deletions
+1 -4
View File
@@ -604,10 +604,7 @@ func (pea *PublicEthAPI) localGetTransactionReceipt(ctx context.Context, hash co
}
receipt := receipts[index]
var signer types.Signer = types.FrontierSigner{}
if tx.Protected() {
signer = types.NewEIP155Signer(tx.ChainId())
}
signer := SignerForTx(tx)
from, _ := types.Sender(signer, tx)
fields := map[string]interface{}{
+9 -3
View File
@@ -144,15 +144,21 @@ func NewRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransa
return nil
}
// 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) *RPCTransaction {
// SignerForTx returns an appropriate Signer for this Transaction
func SignerForTx(tx *types.Transaction) types.Signer {
var signer types.Signer
if tx.Protected() {
signer = types.LatestSignerForChainID(tx.ChainId())
} else {
signer = types.HomesteadSigner{}
}
return signer
}
// 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) *RPCTransaction {
signer := SignerForTx(tx)
from, _ := types.Sender(signer, tx)
v, r, s := tx.RawSignatureValues()
result := &RPCTransaction{