mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
internal/ethapi: Add timestamp to eth_getTransactionByHash (#33709)
Implements https://github.com/ethereum/execution-apis/issues/729 and fixes #33491. It adds blockTimestamp to transaction objects returned by the RPC.
This commit is contained in:
parent
a951aacb70
commit
6530945dcd
5 changed files with 16 additions and 0 deletions
|
|
@ -974,6 +974,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
|
|||
type RPCTransaction struct {
|
||||
BlockHash *common.Hash `json:"blockHash"`
|
||||
BlockNumber *hexutil.Big `json:"blockNumber"`
|
||||
BlockTimestamp *hexutil.Uint64 `json:"blockTimestamp"`
|
||||
From common.Address `json:"from"`
|
||||
Gas hexutil.Uint64 `json:"gas"`
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
|
|
@ -1020,6 +1021,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
|
|||
if blockHash != (common.Hash{}) {
|
||||
result.BlockHash = &blockHash
|
||||
result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber))
|
||||
result.BlockTimestamp = (*hexutil.Uint64)(&blockTime)
|
||||
result.TransactionIndex = (*hexutil.Uint64)(&index)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
|||
Want: `{
|
||||
"blockHash": null,
|
||||
"blockNumber": null,
|
||||
"blockTimestamp": null,
|
||||
"from": "0x71562b71999873db5b286df957af199ec94617f7",
|
||||
"gas": "0x7",
|
||||
"gasPrice": "0x6",
|
||||
|
|
@ -170,6 +171,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
|||
Want: `{
|
||||
"blockHash": null,
|
||||
"blockNumber": null,
|
||||
"blockTimestamp": null,
|
||||
"from": "0x71562b71999873db5b286df957af199ec94617f7",
|
||||
"gas": "0x7",
|
||||
"gasPrice": "0x6",
|
||||
|
|
@ -208,6 +210,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
|||
Want: `{
|
||||
"blockHash": null,
|
||||
"blockNumber": null,
|
||||
"blockTimestamp": null,
|
||||
"from": "0x71562b71999873db5b286df957af199ec94617f7",
|
||||
"gas": "0x7",
|
||||
"gasPrice": "0x6",
|
||||
|
|
@ -254,6 +257,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
|||
Want: `{
|
||||
"blockHash": null,
|
||||
"blockNumber": null,
|
||||
"blockTimestamp": null,
|
||||
"from": "0x71562b71999873db5b286df957af199ec94617f7",
|
||||
"gas": "0x7",
|
||||
"gasPrice": "0x6",
|
||||
|
|
@ -301,6 +305,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
|||
Want: `{
|
||||
"blockHash": null,
|
||||
"blockNumber": null,
|
||||
"blockTimestamp": null,
|
||||
"from": "0x71562b71999873db5b286df957af199ec94617f7",
|
||||
"gas": "0x7",
|
||||
"gasPrice": "0x9",
|
||||
|
|
@ -345,6 +350,7 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txDa
|
|||
Want: `{
|
||||
"blockHash": null,
|
||||
"blockNumber": null,
|
||||
"blockTimestamp": null,
|
||||
"from": "0x71562b71999873db5b286df957af199ec94617f7",
|
||||
"gas": "0x7",
|
||||
"gasPrice": "0x9",
|
||||
|
|
@ -387,6 +393,7 @@ func allBlobTxs(addr common.Address, config *params.ChainConfig) []txData {
|
|||
Want: `{
|
||||
"blockHash": null,
|
||||
"blockNumber": null,
|
||||
"blockTimestamp": null,
|
||||
"from": "0x71562b71999873db5b286df957af199ec94617f7",
|
||||
"gas": "0x6",
|
||||
"gasPrice": "0x5",
|
||||
|
|
@ -3138,6 +3145,7 @@ func TestRPCMarshalBlock(t *testing.T) {
|
|||
{
|
||||
"blockHash": "0x9b73c83b25d0faf7eab854e3684c7e394336d6e135625aafa5c183f27baa8fee",
|
||||
"blockNumber": "0x64",
|
||||
"blockTimestamp": "0x0",
|
||||
"from": "0x0000000000000000000000000000000000000000",
|
||||
"gas": "0x457",
|
||||
"gasPrice": "0x2b67",
|
||||
|
|
@ -3158,6 +3166,7 @@ func TestRPCMarshalBlock(t *testing.T) {
|
|||
{
|
||||
"blockHash": "0x9b73c83b25d0faf7eab854e3684c7e394336d6e135625aafa5c183f27baa8fee",
|
||||
"blockNumber": "0x64",
|
||||
"blockTimestamp": "0x0",
|
||||
"from": "0x0000000000000000000000000000000000000000",
|
||||
"gas": "0x457",
|
||||
"gasPrice": "0x2b67",
|
||||
|
|
@ -3176,6 +3185,7 @@ func TestRPCMarshalBlock(t *testing.T) {
|
|||
{
|
||||
"blockHash": "0x9b73c83b25d0faf7eab854e3684c7e394336d6e135625aafa5c183f27baa8fee",
|
||||
"blockNumber": "0x64",
|
||||
"blockTimestamp": "0x0",
|
||||
"from": "0x0000000000000000000000000000000000000000",
|
||||
"gas": "0x457",
|
||||
"gasPrice": "0x2b67",
|
||||
|
|
@ -3196,6 +3206,7 @@ func TestRPCMarshalBlock(t *testing.T) {
|
|||
{
|
||||
"blockHash": "0x9b73c83b25d0faf7eab854e3684c7e394336d6e135625aafa5c183f27baa8fee",
|
||||
"blockNumber": "0x64",
|
||||
"blockTimestamp": "0x0",
|
||||
"from": "0x0000000000000000000000000000000000000000",
|
||||
"gas": "0x457",
|
||||
"gasPrice": "0x2b67",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
{
|
||||
"blockHash": "0xedb9ccf3a85f67c095ad48abfb0fa09d47179bb0f902078d289042d12428aca5",
|
||||
"blockNumber": "0x9",
|
||||
"blockTimestamp": "0x5a",
|
||||
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
|
||||
"gas": "0x5208",
|
||||
"gasPrice": "0x121a9cca",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
{
|
||||
"blockHash": "0xedb9ccf3a85f67c095ad48abfb0fa09d47179bb0f902078d289042d12428aca5",
|
||||
"blockNumber": "0x9",
|
||||
"blockTimestamp": "0x5a",
|
||||
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
|
||||
"gas": "0x5208",
|
||||
"gasPrice": "0x121a9cca",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
{
|
||||
"blockHash": "0xfda6c7cb7a3a712e0c424909a7724cab0448e89e286617fa8d5fd27f63f28bd2",
|
||||
"blockNumber": "0xb",
|
||||
"blockTimestamp": "0x6e",
|
||||
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
|
||||
"gas": "0x5208",
|
||||
"gasPrice": "0xde56ab3",
|
||||
|
|
|
|||
Loading…
Reference in a new issue