

def transfer(self, asset_transfer_specs, btc_transfer_spec, fees):
    '\n        Creates a transaction for sending assets and bitcoins.\n\n        :param list[(bytes, TransferParameters)] asset_transfer_specs: A list of tuples. In each tuple:\n            - The first element is the ID of an asset.\n            - The second element is the parameters of the transfer.\n        :param TransferParameters btc_transfer_spec: The parameters of the bitcoins being transferred.\n        :param int fees: The fees to include in the transaction.\n        :return: An unsigned transaction for sending assets and bitcoins.\n        :rtype: CTransaction\n        '
    inputs = []
    outputs = []
    asset_quantities = []
    for (asset_id, transfer_spec) in asset_transfer_specs:
        (colored_outputs, collected_amount) = self._collect_colored_outputs(transfer_spec.unspent_outputs, asset_id, transfer_spec.amount)
        inputs.extend(colored_outputs)
        outputs.append(self._get_colored_output(transfer_spec.to_script))
        asset_quantities.append(transfer_spec.amount)
        if (collected_amount > transfer_spec.amount):
            outputs.append(self._get_colored_output(transfer_spec.change_script))
            asset_quantities.append((collected_amount - transfer_spec.amount))
    btc_excess = (sum([input.output.value for input in inputs]) - sum([output.nValue for output in outputs]))
    if (btc_excess < (btc_transfer_spec.amount + fees)):
        (uncolored_outputs, total_amount) = self._collect_uncolored_outputs(btc_transfer_spec.unspent_outputs, ((btc_transfer_spec.amount + fees) - btc_excess))
        inputs.extend(uncolored_outputs)
        btc_excess += total_amount
    change = ((btc_excess - btc_transfer_spec.amount) - fees)
    if (change > 0):
        outputs.append(self._get_uncolored_output(btc_transfer_spec.change_script, change))
    if (btc_transfer_spec.amount > 0):
        outputs.append(self._get_uncolored_output(btc_transfer_spec.to_script, btc_transfer_spec.amount))
    if asset_quantities:
        outputs.insert(0, self._get_marker_output(asset_quantities, b''))
    return bitcoin.core.CTransaction(vin=[bitcoin.core.CTxIn(item.out_point, item.output.script) for item in inputs], vout=outputs)

dataset/ETHPy150Open OpenAssets/openassets/openassets/transactions.py TransactionBuilder.transfer/original