January 2019
Beginner to intermediate
372 pages
11h 17m
English
Transactions are created by constructing valid transaction inputs and outputs. Consumable UTXOs are fetched by the find_tx_outs_for_amount method, as described in the previous section. Transaction inputs will be created for these UTXOs. The leftover amount is used to create a change transaction:
def create_transaction(receiver_address, amount, private_key, unspent_tx_outs, tx_pool):
my_address = get_public_key(private_key)
my_unspent_tx_outs_a = list(filter(lambda utxo: utxo.address == my_address, unspent_tx_outs))
my_unspent_tx_outs = filter_tx_pool_txs(my_unspent_tx_outs_a, tx_pool)
User's unspent transactions are filtered and will be referenced in the transaction inputs:
incl_unspent_tx_outs, left_over_amount ...