Exemple #1
0
 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)
Exemple #2
0
 async def getReceiveTransactionOfSendTransaction(self, tx_hash):
     '''
     Gets the receive transaction corresponding to a given send transaction, if it exists
     '''
     chain = self.get_new_chain()
     receive_tx = chain.get_receive_tx_from_send_tx(tx_hash)
     if receive_tx is not None:
         receive_tx_dict = receive_transaction_to_dict(receive_tx, chain)
         return receive_tx_dict
     else:
         raise BaseRPCError("No receive transaction found for the given send transaction hash")
Exemple #3
0
 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)
Exemple #4
0
 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)