From bc5a4351d39b8c31a6f7a54ead1d67223758a87c Mon Sep 17 00:00:00 2001 From: coffeepots Date: Fri, 17 Aug 2018 20:03:30 +0100 Subject: [PATCH] eth_getTransactionByBlockHashAndIndex --- nimbus/rpc/p2p.nim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nimbus/rpc/p2p.nim b/nimbus/rpc/p2p.nim index 3d83067fb..46fb27835 100644 --- a/nimbus/rpc/p2p.nim +++ b/nimbus/rpc/p2p.nim @@ -336,7 +336,21 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) = ## data: hash of a block. ## quantity: integer of the transaction index position. ## 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: ## Returns information about a transaction by block number and transaction index position.