tfchain/TFChainWallet.py
def drain(self, recipient, miner_fee, unconfirmed=False, data=None, lock=None):
        """
        add all available outputs into as many transactions as required,
        by default only confirmed outputs are used, if unconfirmed=True
        it will use unconfirmed available outputs as well.

        Result can be an empty list if no outputs were available.

        @param recipient: required recipient towards who the drained coins will be sent
        @param the miner fee to be added to all sent transactions
        @param unconfirmed: optionally drain unconfirmed (available) outputs as well
        @param data: optional data that can be attached ot the created transactions (str or bytes), with a max length of 83
        @param lock: optional lock that can be attached to the sent coin outputs
        """
        # define recipient
        recipient = ConditionTypes.from_recipient(recipient, lock=lock)

        # validate miner fee
        if not isinstance(miner_fee, Currency):
            raise TypeError("miner fee has to be a currency")
        if miner_fee == 0:
            raise ValueError("a non-zero miner fee has to be defined")

        # collect all transactions in one list
        transactions = []

        # collect all confirmed (available) outputs
        outputs = self.outputs_available
        if unconfirmed:
            # if also the unconfirmed_avaialble) outputs are desired, let's add them as well
            outputs += self.outputs_unconfirmed_available
        # drain all outputs
        while len(outputs) > 0:
            txn = tftransactions.new()
            txn.data = data
            txn.miner_fee_add(miner_fee)
            # select maximum _MAX_RIVINE_TRANSACTION_INPUTS outputs
            n = min(len(outputs), _MAX_RIVINE_TRANSACTION_INPUTS)
            used_outputs = outputs[:n]
            outputs = outputs[n:] # and update our output list, so we do not double spend
            # compute amount, minus minimum fee and add our only output
            amount = sum([co.value for co in used_outputs]) - miner_fee
            txn.coin_output_add(condition=recipient, value=amount)
            # add the coin inputs
            txn.coin_inputs = [CoinInput.from_coin_output(co) for co in used_outputs]
            # append the transaction
            transactions.append(txn)

        # return all created transactions, if any
        return transactions

        add all available outputs into as many transactions as required,
        by default only confirmed outputs are used, if unconfirmed=True
        it will use unconfirmed available outputs as well.

        Result can be an empty list if no outputs were available.

        @param recipient: required recipient towards who the drained coins will be sent
        @param the miner fee to be added to all sent transactions
        @param unconfirmed: optionally drain unconfirmed (available) outputs as well
        @param data: optional data that can be attached ot the created transactions (str or bytes), with a max length of 83
        @param lock: optional lock that can be attached to the sent coin outputs
        
add all available outputs into as many transactions as required,
by default only confirmed outputs are used, if unconfirmed=True
it will use unconfirmed available outputs as well.

Result can be an empty list if no outputs were available.


add all available outputs into as many transactions as required by default only confirmed outputs are used if unconfirmed = True it will use unconfirmed available outputs as well . Result can be an empty list if no outputs were available .
def drain(self, recipient, miner_fee, unconfirmed=False, data=None, lock=None):
        recipient = ConditionTypes.from_recipient(recipient, lock=lock)
        if not isinstance(miner_fee, Currency):
            raise TypeError("miner fee has to be a currency")
        if miner_fee == 0:
            raise ValueError("a non-zero miner fee has to be defined")
        transactions = []
        outputs = self.outputs_available
        if unconfirmed:
            outputs += self.outputs_unconfirmed_available
        while len(outputs) > 0:
            txn = tftransactions.new()
            txn.data = data
            txn.miner_fee_add(miner_fee)
            n = min(len(outputs), _MAX_RIVINE_TRANSACTION_INPUTS)
            used_outputs = outputs[:n]
            outputs = outputs[n:] 
            amount = sum([co.value for co in used_outputs]) - miner_fee
            txn.coin_output_add(condition=recipient, value=amount)
            txn.coin_inputs = [CoinInput.from_coin_output(co) for co in used_outputs]
            transactions.append(txn)
        return transactions
def drain ( self , recipient , miner_fee , unconfirmed = False , data = None , lock = None ) : recipient = ConditionTypes . from_recipient ( recipient , lock = lock ) if not isinstance ( miner_fee , Currency ) : raise TypeError ( "miner fee has to be a currency" ) if miner_fee == 0 : raise ValueError ( "a non-zero miner fee has to be defined" ) transactions = [ ] outputs = self . outputs_available if unconfirmed : outputs += self . outputs_unconfirmed_available while len ( outputs ) > 0 : txn = tftransactions . new ( ) txn . data = data txn . miner_fee_add ( miner_fee ) n = min ( len ( outputs ) , _MAX_RIVINE_TRANSACTION_INPUTS ) used_outputs = outputs [ : n ] outputs = outputs [ n : ] amount = sum ( [ co . value for co in used_outputs ] ) - miner_fee txn . coin_output_add ( condition = recipient , value = amount ) txn . coin_inputs = [ CoinInput . from_coin_output ( co ) for co in used_outputs ] transactions . append ( txn ) return transactions
add all available outputs into as many transactions as required,
by default only confirmed outputs are used, if unconfirmed=True
it will use unconfirmed available outputs as well.
add all available outputs into as many transactions as required by default only confirmed outputs are used if unconfirmed = True it will use unconfirmed available outputs as well .
"""
        add all available outputs into as many transactions as required,
        by default only confirmed outputs are used, if unconfirmed=True
        it will use unconfirmed available outputs as well.

        Result can be an empty list if no outputs were available.

        @param recipient: required recipient towards who the drained coins will be sent
        @param the miner fee to be added to all sent transactions
        @param unconfirmed: optionally drain unconfirmed (available) outputs as well
        @param data: optional data that can be attached ot the created transactions (str or bytes), with a max length of 83
        @param lock: optional lock that can be attached to the sent coin outputs
        """ # define recipient # validate miner fee # collect all transactions in one list # collect all confirmed (available) outputs # if also the unconfirmed_avaialble) outputs are desired, let's add them as well # drain all outputs # select maximum _MAX_RIVINE_TRANSACTION_INPUTS outputs # and update our output list, so we do not double spend # compute amount, minus minimum fee and add our only output # add the coin inputs # append the transaction # return all created transactions, if any
self
recipient
miner_fee
unconfirmed
data
lock