When a user submits a bitcoin transaction it is validated and finalised through a consistent journey requiring three data structures, each of which has a different role, allowing any node to enforce the protocol and ensure bitcoin cannot be double-spent:
- The UTXO set is the current state of all bitcoin balances within the system
- The blockchain is the transaction record which logs every exchange of bitcoin from one address to another, and
- The mempool is a temporary home for valid transactions awaiting processing into the blockchain.
A transaction begins with a participant’s wallet authorising the spending of bitcoin. That transaction is broadcast to the network, and received by another participant running the bitcoin software. The receiving participant verifies the correctness of the transaction per the rules inscribed in the software. This verification process, detailed by the rule set, requires nodes to search their databases (UTXO set, blockchain and mempool) to determine whether bitcoin can be authentically transferred.
If the transaction is deemed valid by the verification process it is added to the participant’s mempool and propagated to each of the participant’s connected peers. This verification process is repeated for the connected peers and the transaction is continuously ‘gossiped’ throughout the network, effectively being added to each participant’s mempool along the way. Eventually, a mining node will download the transaction in their mempool and subsequently include the transaction into a valid block.
Once the valid block is broadcast, it undergoes a similar verification and propagation process across the network, whereby each participant appends their blockchain and updates their UTXO set and mempool. This intricate process happens for each bitcoin transaction and ensures the correct transfer of bitcoin from wallet to wallet.