Exemplo n.º 1
0
 def atomic_swap(
     self,
     sender_address: str,
     recipient_address: str,
     value: float,
     solvable_utxo: list,
     secret_hash: str = None,
 ) -> BitcoinAtomicSwapTransaction:
     transaction = BitcoinAtomicSwapTransaction(self, sender_address,
                                                recipient_address, value,
                                                solvable_utxo, secret_hash)
     transaction.create_unsigned_transaction()
     return transaction
Exemplo n.º 2
0
 def atomic_swap(
     self,
     sender_address: str,
     recipient_address: str,
     value: float,
     solvable_utxo: list = None,
     secret_hash: str = None,
 ) -> BitcoinAtomicSwapTransaction:
     if not solvable_utxo:
         solvable_utxo = self.get_utxo(sender_address, value)
         if not solvable_utxo:
             logger.error(f'Cannot get UTXO for address {sender_address}')
             return
     transaction = BitcoinAtomicSwapTransaction(self, sender_address,
                                                recipient_address, value,
                                                solvable_utxo, secret_hash)
     transaction.create_unsigned_transaction()
     return transaction
Exemplo n.º 3
0
    def atomic_swap(
        self,
        sender_address: str,
        recipient_address: str,
        value: float,
        solvable_utxo: list = None,
        secret_hash: str = None,
    ) -> Optional[BitcoinAtomicSwapTransaction]:
        '''
        Creates atomic swap unsigned transaction object.

        Args:
            sender_address (str): wallet address of the sender
            recipient_address (str): wallet address of the recipient
            value (float): amount to swap
            solvable_utxo (list): optional list of UTXO objects. If None then it will try to find UTXO automatically
                by using the `get_utxo` method.
            secret_hash (str): optional secret hash to be used in transaction. If None then the new hash
                will be generated.

        Returns:
            BitcoinAtomicSwapTransaction, None: unsigned Atomic Swap transaction object or None if something went wrong

        Example:
            >>> from clove.network import BitcoinTestNet
            >>> network = BitcoinTestNet()
            >>> network.atomic_swap('msJ2ucZ2NDhpVzsiNE5mGUFzqFDggjBVTM', 'mmJtKA92Mxqfi3XdyGReza69GjhkwAcBN1', 2.4)
            <clove.network.bitcoin.transaction.BitcoinAtomicSwapTransaction at 0x7f989439d630>
        '''
        if not solvable_utxo:
            solvable_utxo = self.get_utxo(sender_address, value)
            if not solvable_utxo:
                logger.error(f'Cannot get UTXO for address {sender_address}')
                return
        transaction = BitcoinAtomicSwapTransaction(self, sender_address,
                                                   recipient_address, value,
                                                   solvable_utxo, secret_hash)
        transaction.create_unsigned_transaction()
        return transaction