public ResultWrapper <TransactionWithProof> proof_getTransactionByHash(Keccak txHash, bool includeHeader) { Keccak blockHash = _receiptFinder.FindBlockHash(txHash); if (blockHash == null) { return(ResultWrapper <TransactionWithProof> .Fail($"{txHash} receipt (transaction) could not be found", ErrorCodes.ResourceNotFound)); } SearchResult <Block> searchResult = _blockFinder.SearchForBlock(new BlockParameter(blockHash)); if (searchResult.IsError) { return(ResultWrapper <TransactionWithProof> .Fail(searchResult)); } Block block = searchResult.Object; TxReceipt receipt = _receiptFinder.Get(block).ForTransaction(txHash); Transaction[] txs = block.Transactions; Transaction transaction = txs[receipt.Index]; TransactionWithProof txWithProof = new TransactionWithProof(); txWithProof.Transaction = new TransactionForRpc(block.Hash, block.Number, receipt.Index, transaction); txWithProof.TxProof = BuildTxProofs(txs, _specProvider.GetSpec(block.Number), receipt.Index); if (includeHeader) { txWithProof.BlockHeader = _headerDecoder.Encode(block.Header).Bytes; } return(ResultWrapper <TransactionWithProof> .Success(txWithProof)); }
public ResultWrapper <UInt256?> eth_getBlockTransactionCountByHash(Keccak blockHash) { SearchResult <Block> searchResult = _blockFinder.SearchForBlock(new BlockParameter(blockHash)); if (searchResult.IsError) { return(ResultWrapper <UInt256?> .Fail(searchResult)); } return(ResultWrapper <UInt256?> .Success((UInt256)searchResult.Object.Transactions.Length)); }
public ResultWrapper <ReceiptForRpc[]> parity_getBlockReceipts(BlockParameter blockParameter) { SearchResult <Block> searchResult = _blockFinder.SearchForBlock(blockParameter); if (searchResult.IsError) { return(ResultWrapper <ReceiptForRpc[]> .Fail(searchResult)); } Block block = searchResult.Object; TxReceipt[] receipts = _receiptFinder.Get(block) ?? new TxReceipt[block.Transactions.Length]; IEnumerable <ReceiptForRpc> result = receipts.Zip(block.Transactions, (r, t) => new ReceiptForRpc(t.Hash, r)); return(ResultWrapper <ReceiptForRpc[]> .Success(result.ToArray())); }
public ResultWrapper <ReceiptForRpc[]> parity_getBlockReceipts(BlockParameter blockParameter) { SearchResult <Block> searchResult = _blockFinder.SearchForBlock(blockParameter); if (searchResult.IsError) { return(ResultWrapper <ReceiptForRpc[]> .Fail(searchResult)); } Block block = searchResult.Object; TxReceipt[] receipts = _receiptFinder.Get(block) ?? new TxReceipt[block.Transactions.Length]; bool isEip1559Enabled = _specProvider.GetSpec(block.Number).IsEip1559Enabled; IEnumerable <ReceiptForRpc> result = receipts .Zip(block.Transactions, (r, t) => new ReceiptForRpc(t.Hash, r, t.CalculateEffectiveGasPrice(isEip1559Enabled, block.BaseFeePerGas), receipts.GetBlockLogFirstIndex(r.Index))); ReceiptForRpc[] resultAsArray = result.ToArray(); return(ResultWrapper <ReceiptForRpc[]> .Success(resultAsArray)); }