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

        Returns the sent transaction.

        @param outputid: the identifier of the coin output that contains the atomic swap contract
        @param secret: secret, matching the contract's secret hash, used to redeem the 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 defined secret
        if not contract.verify_secret(secret):
            raise tfchain.errors.AtomicSwapInvalidSecret(contract=contract)

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

        # create the fulfillment
        fulfillment = FulfillmentTypes.atomic_swap_new(secret=secret)

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

        Redeem an unspent Atomic Swap contract.

        Returns the sent transaction.

        @param outputid: the identifier of the coin output that contains the atomic swap contract
        @param secret: secret, matching the contract's secret hash, used to redeem the contract
        @param data: optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
        
Redeem an unspent Atomic Swap contract.
Returns the sent transaction.
Redeem an unspent Atomic Swap contract . Returns the sent transaction .
def redeem(self, outputid, secret, 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)
        if not contract.verify_secret(secret):
            raise tfchain.errors.AtomicSwapInvalidSecret(contract=contract)
        if contract.receiver not in self._wallet.addresses:
            raise tfchain.errors.AtomicSwapForbidden(message="unauthorized to redeem: wallet does not contain receiver address {}".format(contract.receiver), contract=contract)
        fulfillment = FulfillmentTypes.atomic_swap_new(secret=secret)
        return self._claim_contract(contract=contract, as_sender=False, fulfillment=fulfillment, data=data)
def redeem ( self , outputid , secret , 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 ) if not contract . verify_secret ( secret ) : raise tfchain . errors . AtomicSwapInvalidSecret ( contract = contract ) if contract . receiver not in self . _wallet . addresses : raise tfchain . errors . AtomicSwapForbidden ( message = "unauthorized to redeem: wallet does not contain receiver address {}" . format ( contract . receiver ) , contract = contract ) fulfillment = FulfillmentTypes . atomic_swap_new ( secret = secret ) return self . _claim_contract ( contract = contract , as_sender = False , fulfillment = fulfillment , data = data )
Redeem an unspent Atomic Swap contract.
Redeem an unspent Atomic Swap contract .
"""
        Redeem an unspent Atomic Swap contract.

        Returns the sent transaction.

        @param outputid: the identifier of the coin output that contains the atomic swap contract
        @param secret: secret, matching the contract's secret hash, used to redeem the 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 defined secret # ensure this wallet is authorized to be the receiver # 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
secret
secret, matching the contract's secret hash, used to redeem the contract
secret matching the contract ' s secret hash used to redeem the 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