eth_getTransactionByBlockHashAndIndex

This commit is contained in:
coffeepots 2018-08-17 20:03:30 +01:00
parent 19c68422bc
commit 3b53f18b84
1 changed files with 15 additions and 1 deletions

View File

@ -336,7 +336,21 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) =
## data: hash of a block. ## data: hash of a block.
## quantity: integer of the transaction index position. ## quantity: integer of the transaction index position.
## Returns requested transaction information. ## Returns requested transaction information.
discard let
blockHash = data.string.strToHash()
body = chain.getBlockBody(blockHash)
header = chain.getBlockHeader(blockHash)
transaction = body.transactions[quantity]
vmState = newBaseVMState(header, chain)
addressDb = vmState.chaindb.getStateDb(blockHash, true)
# TODO: Get/calculate address for this transaction
address = ZERO_ADDRESS
txCount = addressDb.getNonce(address)
txHash = transaction.rlpHash
# TODO: Fetch account gas
accountGas = 0
populateTransactionObject(transaction, txHash, txCount, quantity, header, accountGas)
rpcsrv.rpc("eth_getTransactionByBlockNumberAndIndex") do(quantityTag: string, quantity: int) -> TransactionObject: rpcsrv.rpc("eth_getTransactionByBlockNumberAndIndex") do(quantityTag: string, quantity: int) -> TransactionObject:
## Returns information about a transaction by block number and transaction index position. ## Returns information about a transaction by block number and transaction index position.