async def getTransactionByHash(self, tx_hash): chain = self.get_new_chain() try: tx = chain.get_canonical_transaction(tx_hash) except TransactionNotFound: raise BaseRPCError("Transaction with hash {} not found on canonical chain.".format(encode_hex(tx_hash))) if isinstance(tx, BaseReceiveTransaction): return receive_transaction_to_dict(tx, chain) else: return transaction_to_dict(tx, chain)
async def getTransactionByBlockHashAndIndex(self, block_hash, index): try: tx = self._chain.get_transaction_by_block_hash_and_index(block_hash, index) except HeaderNotFound: raise BaseRPCError('No block found with the given block hash') if isinstance(tx, BaseReceiveTransaction): # receive tx return receive_transaction_to_dict(tx, self._chain) else: # send tx return transaction_to_dict(tx, self._chain)
async def getTransactionByBlockNumberAndIndex(self, at_block, index, chain_address): try: block_hash = self._chain.chaindb.get_canonical_block_hash(chain_address=chain_address, block_number=at_block) except HeaderNotFound: raise BaseRPCError('No block found with the given chain address and block number') tx = self._chain.get_transaction_by_block_hash_and_index(block_hash, index) if isinstance(tx, BaseReceiveTransaction): # receive tx return receive_transaction_to_dict(tx, self._chain) else: # send tx return transaction_to_dict(tx, self._chain)
async def getTransactionByBlockNumberAndIndex( self, at_block: Union[str, int], index: int) -> Dict[str, str]: block = await get_block_at_number(self._chain, at_block) transaction = block.transactions[index] return transaction_to_dict(transaction)
async def getTransactionByBlockHashAndIndex(self, block_hash: Hash32, index: int) -> Dict[str, str]: block = await self._chain.coro_get_block_by_hash(block_hash) transaction = block.transactions[index] return transaction_to_dict(transaction)
def getTransactionByBlockNumberAndIndex(self, at_block, index): block = get_block_at_number(self._chain, at_block) transaction = block.transactions[index] return transaction_to_dict(transaction)
def getTransactionByBlockHashAndIndex(self, block_hash, index): block = self._chain.get_block_by_hash(block_hash) transaction = block.transactions[index] return transaction_to_dict(transaction)