tfchain/TFChainWallet.py
def _claim_contract(self, contract, as_sender, fulfillment, data):
        """
        claim an unspent atomic swap contract
        """
        # create the contract and fill in the easy content
        txn = tftransactions.new()
        miner_fee = self._minium_miner_fee
        txn.miner_fee_add(miner_fee)
        txn.data = data
        # define the coin input
        txn.coin_input_add(parentid=contract.outputid, fulfillment=fulfillment, parent_output=contract.coin_output)
        # and the coin output
        txn.coin_output_add(
            condition=ConditionTypes.unlockhash_new(contract.sender if as_sender else contract.receiver),
            value=contract.amount-miner_fee)

        # get all signature requests
        sig_requests = txn.signature_requests_new()
        if len(sig_requests) == 0:
            raise Exception("BUG: sig requests should not be empty at this point, please fix or report as an issue")

        # fulfill the signature requests that we can fulfill
        for request in sig_requests:
            try:
                key_pair = self._wallet.key_pair_get(request.wallet_address)
                input_hash = request.input_hash_new(public_key=key_pair.public_key)
                signature = key_pair.sign(input_hash)
                request.signature_fulfill(public_key=key_pair.public_key, signature=signature)
            except KeyError:
                pass # this is acceptable due to how we directly try the key_pair_get method

        # submit if possible
        submit = txn.is_fulfilled()
        if not submit:
            raise Exception("BUG: transaction should be fulfilled at ths point, please fix or report as an isuse")

        # assign transactionid
        txn.id = self._transaction_put(transaction=txn)
        # update balance
        balance = self._wallet.balance
        addresses = self._wallet.addresses
        for idx, co in enumerate(txn.coin_outputs):
            if str(co.condition.unlockhash) in addresses:
                co.id = txn.coin_outputid_new(idx)
                balance.output_add(co, confirmed=False, spent=False)

        # return the txn
        return txn

        claim an unspent atomic swap contract
        
claim an unspent atomic swap contract
claim an unspent atomic swap contract
def _claim_contract(self, contract, as_sender, fulfillment, data):
        txn = tftransactions.new()
        miner_fee = self._minium_miner_fee
        txn.miner_fee_add(miner_fee)
        txn.data = data
        txn.coin_input_add(parentid=contract.outputid, fulfillment=fulfillment, parent_output=contract.coin_output)
        txn.coin_output_add(
            condition=ConditionTypes.unlockhash_new(contract.sender if as_sender else contract.receiver),
            value=contract.amount-miner_fee)
        sig_requests = txn.signature_requests_new()
        if len(sig_requests) == 0:
            raise Exception("BUG: sig requests should not be empty at this point, please fix or report as an issue")
        for request in sig_requests:
            try:
                key_pair = self._wallet.key_pair_get(request.wallet_address)
                input_hash = request.input_hash_new(public_key=key_pair.public_key)
                signature = key_pair.sign(input_hash)
                request.signature_fulfill(public_key=key_pair.public_key, signature=signature)
            except KeyError:
                pass 
        submit = txn.is_fulfilled()
        if not submit:
            raise Exception("BUG: transaction should be fulfilled at ths point, please fix or report as an isuse")
        txn.id = self._transaction_put(transaction=txn)
        balance = self._wallet.balance
        addresses = self._wallet.addresses
        for idx, co in enumerate(txn.coin_outputs):
            if str(co.condition.unlockhash) in addresses:
                co.id = txn.coin_outputid_new(idx)
                balance.output_add(co, confirmed=False, spent=False)
        return txn
def _claim_contract ( self , contract , as_sender , fulfillment , data ) : txn = tftransactions . new ( ) miner_fee = self . _minium_miner_fee txn . miner_fee_add ( miner_fee ) txn . data = data txn . coin_input_add ( parentid = contract . outputid , fulfillment = fulfillment , parent_output = contract . coin_output ) txn . coin_output_add ( condition = ConditionTypes . unlockhash_new ( contract . sender if as_sender else contract . receiver ) , value = contract . amount - miner_fee ) sig_requests = txn . signature_requests_new ( ) if len ( sig_requests ) == 0 : raise Exception ( "BUG: sig requests should not be empty at this point, please fix or report as an issue" ) for request in sig_requests : try : key_pair = self . _wallet . key_pair_get ( request . wallet_address ) input_hash = request . input_hash_new ( public_key = key_pair . public_key ) signature = key_pair . sign ( input_hash ) request . signature_fulfill ( public_key = key_pair . public_key , signature = signature ) except KeyError : pass submit = txn . is_fulfilled ( ) if not submit : raise Exception ( "BUG: transaction should be fulfilled at ths point, please fix or report as an isuse" ) txn . id = self . _transaction_put ( transaction = txn ) balance = self . _wallet . balance addresses = self . _wallet . addresses for idx , co in enumerate ( txn . coin_outputs ) : if str ( co . condition . unlockhash ) in addresses : co . id = txn . coin_outputid_new ( idx ) balance . output_add ( co , confirmed = False , spent = False ) return txn
claim an unspent atomic swap contract
claim an unspent atomic swap contract
"""
        claim an unspent atomic swap contract
        """ # create the contract and fill in the easy content # define the coin input # and the coin output # get all signature requests # fulfill the signature requests that we can fulfill # this is acceptable due to how we directly try the key_pair_get method # submit if possible # assign transactionid # update balance # return the txn
self
contract
as_sender
fulfillment
data