Merge pull request #3663 from rlan35/main

Add ethHash to hmy v1 rpc
pull/3665/head v4.0.1
Rongjian Lan 4 years ago committed by GitHub
commit 343dbe89b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      rpc/v1/types.go

@ -38,6 +38,7 @@ type BlockWithTxHash struct {
ReceiptsRoot common.Hash `json:"receiptsRoot"` ReceiptsRoot common.Hash `json:"receiptsRoot"`
Uncles []common.Hash `json:"uncles"` Uncles []common.Hash `json:"uncles"`
Transactions []common.Hash `json:"transactions"` Transactions []common.Hash `json:"transactions"`
EthTransactions []common.Hash `json:"transactionsInEthHash"`
StakingTxs []common.Hash `json:"stakingTransactions"` StakingTxs []common.Hash `json:"stakingTransactions"`
Signers []string `json:"signers,omitempty"` Signers []string `json:"signers,omitempty"`
} }
@ -78,6 +79,7 @@ type Transaction struct {
Gas hexutil.Uint64 `json:"gas"` Gas hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"` GasPrice *hexutil.Big `json:"gasPrice"`
Hash common.Hash `json:"hash"` Hash common.Hash `json:"hash"`
EthHash common.Hash `json:"ethHash"`
Input hexutil.Bytes `json:"input"` Input hexutil.Bytes `json:"input"`
Nonce hexutil.Uint64 `json:"nonce"` Nonce hexutil.Uint64 `json:"nonce"`
To string `json:"to"` To string `json:"to"`
@ -259,6 +261,7 @@ func NewTransaction(
Gas: hexutil.Uint64(tx.GasLimit()), Gas: hexutil.Uint64(tx.GasLimit()),
GasPrice: (*hexutil.Big)(tx.GasPrice()), GasPrice: (*hexutil.Big)(tx.GasPrice()),
Hash: tx.Hash(), Hash: tx.Hash(),
EthHash: tx.ConvertToEth().Hash(),
Input: hexutil.Bytes(tx.Data()), Input: hexutil.Bytes(tx.Data()),
Nonce: hexutil.Uint64(tx.Nonce()), Nonce: hexutil.Uint64(tx.Nonce()),
Value: (*hexutil.Big)(tx.Value()), Value: (*hexutil.Big)(tx.Value()),
@ -606,11 +609,13 @@ func NewBlockWithTxHash(
ReceiptsRoot: head.ReceiptHash(), ReceiptsRoot: head.ReceiptHash(),
Uncles: []common.Hash{}, Uncles: []common.Hash{},
Transactions: []common.Hash{}, Transactions: []common.Hash{},
EthTransactions: []common.Hash{},
StakingTxs: []common.Hash{}, StakingTxs: []common.Hash{},
} }
for _, tx := range b.Transactions() { for _, tx := range b.Transactions() {
blk.Transactions = append(blk.Transactions, tx.Hash()) blk.Transactions = append(blk.Transactions, tx.Hash())
blk.EthTransactions = append(blk.EthTransactions, tx.ConvertToEth().Hash())
} }
if blockArgs.InclStaking { if blockArgs.InclStaking {

Loading…
Cancel
Save