async def is_transaction_in_mempool(api, tx_id: bytes32) -> bool:
     try:
         val = await api.get_transaction({"wallet_id": user_wallet_id, "transaction_id": tx_id.hex()})
     except ValueError:
         return False
     for _, mis, _ in val["transaction"].sent_to:
         if (
             MempoolInclusionStatus(mis) == MempoolInclusionStatus.SUCCESS
             or MempoolInclusionStatus(mis) == MempoolInclusionStatus.PENDING
         ):
             return True
     return False
Exemple #2
0
 async def transaction_ack(self, ack: wallet_protocol.TransactionAck,
                           peer: WSChiaConnection):
     """
     This is an ack for our previous SendTransaction call. This removes the transaction from
     the send queue if we have sent it to enough nodes.
     """
     assert peer.peer_node_id is not None
     name = peer.peer_node_id.hex()
     status = MempoolInclusionStatus(ack.status)
     if self.wallet_node.wallet_state_manager is None or self.wallet_node.backup_initialized is False:
         return
     if status == MempoolInclusionStatus.SUCCESS:
         self.wallet_node.log.info(
             f"SpendBundle has been received and accepted to mempool by the FullNode. {ack}"
         )
     elif status == MempoolInclusionStatus.PENDING:
         self.wallet_node.log.info(
             f"SpendBundle has been received (and is pending) by the FullNode. {ack}"
         )
     else:
         self.wallet_node.log.warning(
             f"SpendBundle has been rejected by the FullNode. {ack}")
     if ack.error is not None:
         await self.wallet_node.wallet_state_manager.remove_from_queue(
             ack.txid, name, status, Err[ack.error])
     else:
         await self.wallet_node.wallet_state_manager.remove_from_queue(
             ack.txid, name, status, None)
 def is_in_mempool(self) -> bool:
     # If one of the nodes we sent it to responded with success, we set it to success
     for (_, mis, _) in self.sent_to:
         if MempoolInclusionStatus(mis) == MempoolInclusionStatus.SUCCESS:
             return True
     # Note, transactions pending inclusion (pending) return false
     return False
Exemple #4
0
 async def transaction_ack(self, ack: wallet_protocol.TransactionAck,
                           peer: WSChiaConnection):
     """
     This is an ack for our previous SendTransaction call. This removes the transaction from
     the send queue if we have sent it to enough nodes.
     """
     assert peer.peer_node_id is not None
     name = peer.peer_node_id.hex()
     status = MempoolInclusionStatus(ack.status)
     if self.wallet_node.wallet_state_manager is None:
         return None
     if status == MempoolInclusionStatus.SUCCESS:
         self.wallet_node.log.info(
             f"SpendBundle has been received and accepted to mempool by the FullNode. {ack}"
         )
     elif status == MempoolInclusionStatus.PENDING:
         self.wallet_node.log.info(
             f"SpendBundle has been received (and is pending) by the FullNode. {ack}"
         )
     else:
         if not self.wallet_node.is_trusted(
                 peer
         ) and ack.error == Err.NO_TRANSACTIONS_WHILE_SYNCING.name:
             self.wallet_node.log.info(
                 f"Peer {peer.get_peer_info()} is not synced, closing connection"
             )
             await peer.close()
             return
         self.wallet_node.log.warning(
             f"SpendBundle has been rejected by the FullNode. {ack}")
     if ack.error is not None:
         await self.wallet_node.wallet_state_manager.remove_from_queue(
             ack.txid, name, status, Err[ack.error])
     else:
         await self.wallet_node.wallet_state_manager.remove_from_queue(
             ack.txid, name, status, None)