Skip to content

Commit 96ab8e1

Browse files
fjlkaralabe
authored andcommitted
internal/ethapi: return null inclusion info for pending transactions (#19901)
This change ensures 'blockHash', 'blockNumber' and 'transactionIndex' are set to null for pending transactions. This behavior is required by the Ethereum JSON-RPC spec.
1 parent f34a3a6 commit 96ab8e1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/ethapi/api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ func (s *PublicBlockChainAPI) rpcMarshalBlock(b *types.Block, inclTx bool, fullT
10431043

10441044
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
10451045
type RPCTransaction struct {
1046-
BlockHash common.Hash `json:"blockHash"`
1046+
BlockHash *common.Hash `json:"blockHash"`
10471047
BlockNumber *hexutil.Big `json:"blockNumber"`
10481048
From common.Address `json:"from"`
10491049
Gas hexutil.Uint64 `json:"gas"`
@@ -1052,7 +1052,7 @@ type RPCTransaction struct {
10521052
Input hexutil.Bytes `json:"input"`
10531053
Nonce hexutil.Uint64 `json:"nonce"`
10541054
To *common.Address `json:"to"`
1055-
TransactionIndex hexutil.Uint `json:"transactionIndex"`
1055+
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
10561056
Value *hexutil.Big `json:"value"`
10571057
V *hexutil.Big `json:"v"`
10581058
R *hexutil.Big `json:"r"`
@@ -1083,9 +1083,9 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
10831083
S: (*hexutil.Big)(s),
10841084
}
10851085
if blockHash != (common.Hash{}) {
1086-
result.BlockHash = blockHash
1086+
result.BlockHash = &blockHash
10871087
result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber))
1088-
result.TransactionIndex = hexutil.Uint(index)
1088+
result.TransactionIndex = (*hexutil.Uint64)(&index)
10891089
}
10901090
return result
10911091
}

0 commit comments

Comments
 (0)