Bitcoin trading, the most important part of the bitcoin system, is often referred to as “UTXO” in the process of bitcoin trading. There is a saying that you can never have money in your Bitcoin wallet, but you can have the power to spend it.
If you were told that there are no such things as “accounts” or “balances” in the bitcoin world, you’d think it would be strange. “When my wallet App tells me I have XX bitcoins lying around in my wallet?” you ask.
In this issue of Blockchain 100 Lectures, we will talk about UTXO.
1
Past knowledge
Bitcoin transactions are the most important part of the bitcoin system. Its life cycle is shown below:
Its life cycle begins the moment it is created, its birth.
The bitcoin transaction is then encrypted with one or more signatures that mark permission to use the bitcoin funds to which the transaction is directed.
The bitcoin transaction is then broadcast into the Bitcoin network, where each node (bitcoin transaction participant) validates and broadcasts the transaction over the network until the transaction is received by most of the nodes in the network.
Each Bitcoin node is connected to a number of other nodes to form a large network. Each node verifies each other after receiving a transaction, propagates it to the other nodes if it is valid, and rejects it and returns if it is not. A valid transaction can spread across the web in seconds.
Eventually, bitcoin transactions are verified by a mining node and added to a block on the blockchain that records many Bitcoin transactions.
Once a Bitcoin transaction is recorded on the blockchain and confirmed by enough subsequent blocks, it becomes part of the master ledger of Bitcoin and is recognized as a valid transaction by all bitcoin exchange participants.
Bitcoin funds allocated by the transaction to a new owner can then be used in new transactions — extending the chain of ownership and once again starting a new bitcoin transaction life cycle.
2
UTXO
A Bitcoin transaction is a data structure with input values and output values.
The basic unit of bitcoin Transaction is an unused Transaction Output, or UTXO, which stands for “Unspent Transaction Output.”
There are no accounts or balances in the bitcoin world, only UTXOs scattered across the blockchain.
UTXO is a set amount of Bitcoin currency that can no longer be divided, locked up by the owner, or recorded in the blockchain and recognized as a monetary unit by the entire network.
The Bitcoin network monitors all available (unspent) UTXOs in the millions. When a user receives a Bitcoin, the amount is recorded in the blockchain as a UTXO. In this way, a user’s Bitcoin is treated as a UTXO spread across hundreds of transactions and hundreds of blocks.
In reality, there is no place to store Bitcoin addresses or account balances, just scattered UTXOs that are locked by their owners.
The concept of “a user’s Bitcoin balance” is a spin-off created through the Bitcoin wallet app. The Bitcoin wallet calculates a user’s balance by scanning the blockchain and aggregating all UTXOs belonging to that user.
— Mastering Bitcoin
To understand UTXO, let’s assume a total of these scenarios: Joe mines 12.5 Bitcoins, and after a few days, he pays Out 2.5 of them to Joe. A few days later, he and Li Si each contributed 2.5 bitcoins to make up 5 bitcoins for Wang Wu.
If the design is based on the traditional account model, zhang, Li and Wang each have one account in the database, their account changes are shown in the figure below:
But in Bitcoin, this process is done via UTXO, as shown below:
As can be seen from the figure, the output of the last transaction is the input of the next transaction, forming a transaction chain. Every transfer in the Bitcoin world can be traced back to the last transaction, all the way back to the block miners dug up when it was created. In a transaction, the UTXOs consumed by the transaction are called trade inputs, and the UTXOs created by the transaction are called trade outputs.
The Bitcoin wallet calculates a user’s balance by scanning the blockchain and aggregating all UTXOs belonging to that user. When a user makes a payment, his wallet constructs a transaction by selecting the available UTXO. Once a UTXO is selected, the wallet generates an unlock script for it that contains a signature, the equivalent of opening the till to withdraw money and make a payment.
The advantage of UTXO
In the physical world, the value of money is easy to transfer, and metal money/paper money is a good way to transfer value; In the digital world, bitcoin signs a digital signature on the previous transaction and the public key of the next owner, which is appended to the end of the bitcoin and sent to the next owner. Through the design mechanism of UTXO, each transaction can only be used once, which solves the problem of double payment in the digital world, thus realizing value transfer.
In addition, because the whole network only records UTXO, old historical data can be tailored in the future, unlike the centralized account database system, which needs to record all transaction records (addition, deletion and modification), old data can not be discarded, thus reducing the problem of the rapid growth of the entire network data.
Content source: Meng Yan’s blockchain thinking, Na Mei Years, U Zan community
Sorting: Cynthia
Block chain 100 lectures: Meckel tree to protect block chain data cannot be tampered with, want to change the root to chop down the tree!
Blockchain lecture 100:4 Concepts that public Key algorithms cannot But know
Blockchain lecture 100: It is said that 80% of people can’t figure out hashing algorithms
Blockchain 100 Lecture: Ethereum ETH Mining Tutorial
Activity recommended
Recommended: technical Sharon | 0 start to write the contracts, the etheric fang developers learning path (tianjin)
Scan the QR code below or click “Read the original” to sign up