January 2019
Beginner to intermediate
372 pages
11h 17m
English
A transaction input will always refer to a UTXO. A list of UTXOs is maintained locally. This list is updated whenever a transaction is processed, and is referred to during transaction validation. Although this list could be generated at any time by traversing the entire blockchain, it is maintained in memory to facilitate speedy transaction validation:
class UnspentTxOut:
def __init__(self, tx_out_id, tx_out_index, address, amount):
self.tx_out_id = tx_out_id
self.tx_out_index = tx_out_index
self.address = address
self.amount = amount
The list of UTXOs is a simple list that is initially created by processing the genesis transaction.
self.unspent_tx_outs = process_transactions([self.genesis_transaction], [], 0)
Whenever the node creates ...