tfchain/TFChainWallet.py
def refund(self, outputid, data=None):
        """
        Refund an unspent Atomic Swap contract.

        Returns the sent transaction.

        @param outputid: the identifier of the coin output that contains the atomic swap contract
        @param data: optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
        """
        co = None
        spend_txn = None
        # try to fetch the contract
        try:
            # try to fetch the coin output that is expected to contain the secret
            co, _, spend_txn = self._wallet.client.coin_output_get(outputid)
        except tfchain.errors.ExplorerNoContent as exc:
            raise tfchain.errors.AtomicSwapContractNotFound(outputid=outputid) from exc
        # generate the contract
        contract = AtomicSwapContract(coinoutput=co, unspent=False, current_timestamp=self._chain_time) # either it is spent already or we'll spend it
        # check if the contract hasn't been spent already
        if spend_txn is not None:
            # if a spend transaction exists,
            # it means the contract was already spend, and can therefore no longer be redeemed
            raise tfchain.errors.AtomicSwapContractSpent(contract=contract, transaction=spend_txn)
        # verify the contract can be refunded already
        time = self._chain_time
        if time < contract.refund_timestamp:
            raise tfchain.errors.AtomicSwapForbidden(
                message="unauthorized to refund: contract can only be refunded since {}".format(epoch2HRDateTime(contract.refund_timestamp)),
                contract=contract)

        # ensure this wallet is authorized to be the sender (refunder)
        if contract.sender not in self._wallet.addresses:
            raise tfchain.errors.AtomicSwapForbidden(message="unauthorized to refund: wallet does not contain sender address {}".format(contract.sender), contract=contract)

        # create the fulfillment
        fulfillment = FulfillmentTypes.atomic_swap_new()

        # create, sign and submit the transaction
        return self._claim_contract(contract=contract, as_sender=True, fulfillment=fulfillment, data=data)

        Refund an unspent Atomic Swap contract.

        Returns the sent transaction.

        @param outputid: the identifier of the coin output that contains the atomic swap contract
        @param data: optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
        
Refund an unspent Atomic Swap contract.
Returns the sent transaction.
Refund an unspent Atomic Swap contract . Returns the sent transaction .
def refund(self, outputid, data=None):
        co = None
        spend_txn = None
        try:
            co, _, spend_txn = self._wallet.client.coin_output_get(outputid)
        except tfchain.errors.ExplorerNoContent as exc:
            raise tfchain.errors.AtomicSwapContractNotFound(outputid=outputid) from exc
        contract = AtomicSwapContract(coinoutput=co, unspent=False, current_timestamp=self._chain_time) 
        if spend_txn is not None:
            raise tfchain.errors.AtomicSwapContractSpent(contract=contract, transaction=spend_txn)
        time = self._chain_time
        if time < contract.refund_timestamp:
            raise tfchain.errors.AtomicSwapForbidden(
                message="unauthorized to refund: contract can only be refunded since {}".format(epoch2HRDateTime(contract.refund_timestamp)),
                contract=contract)
        if contract.sender not in self._wallet.addresses:
            raise tfchain.errors.AtomicSwapForbidden(message="unauthorized to refund: wallet does not contain sender address {}".format(contract.sender), contract=contract)
        fulfillment = FulfillmentTypes.atomic_swap_new()
        return self._claim_contract(contract=contract, as_sender=True, fulfillment=fulfillment, data=data)
def refund ( self , outputid , data = None ) : co = None spend_txn = None try : co , _ , spend_txn = self . _wallet . client . coin_output_get ( outputid ) except tfchain . errors . ExplorerNoContent as exc : raise tfchain . errors . AtomicSwapContractNotFound ( outputid = outputid ) from exc contract = AtomicSwapContract ( coinoutput = co , unspent = False , current_timestamp = self . _chain_time ) if spend_txn is not None : raise tfchain . errors . AtomicSwapContractSpent ( contract = contract , transaction = spend_txn ) time = self . _chain_time if time < contract . refund_timestamp : raise tfchain . errors . AtomicSwapForbidden ( message = "unauthorized to refund: contract can only be refunded since {}" . format ( epoch2HRDateTime ( contract . refund_timestamp ) ) , contract = contract ) if contract . sender not in self . _wallet . addresses : raise tfchain . errors . AtomicSwapForbidden ( message = "unauthorized to refund: wallet does not contain sender address {}" . format ( contract . sender ) , contract = contract ) fulfillment = FulfillmentTypes . atomic_swap_new ( ) return self . _claim_contract ( contract = contract , as_sender = True , fulfillment = fulfillment , data = data )
Refund an unspent Atomic Swap contract.
Refund an unspent Atomic Swap contract .
"""
        Refund an unspent Atomic Swap contract.

        Returns the sent transaction.

        @param outputid: the identifier of the coin output that contains the atomic swap contract
        @param data: optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
        """ # try to fetch the contract # try to fetch the coin output that is expected to contain the secret # generate the contract # either it is spent already or we'll spend it # check if the contract hasn't been spent already # if a spend transaction exists, # it means the contract was already spend, and can therefore no longer be redeemed # verify the contract can be refunded already # ensure this wallet is authorized to be the sender (refunder) # create the fulfillment # create, sign and submit the transaction
self
outputid
the identifier of the coin output that contains the atomic swap contract
the identifier of the coin output that contains the atomic swap contract
data
optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
optional data that can be attached ot the sent transaction ( str or bytes ) with a max length of 83