Bitcoin, the ancestor of blockchain 4: unique transaction design

Yin Cheng 2021-11-24 08:11:05 阅读数:166

bitcoin ancestor blockchain unique transaction


In a simple transaction above , We solved who sent the message by digital signature . We didn't consider a problem , That is, if Yin Cheng is a loser , He didn't even 5 individual BTC What do I do ? Maybe you can easily think of , Verify that the balance in his account is greater than 5BTC No, it's OK ? But there is no concept of account balance in bitcoin , And only trading , Everyone has a history of all transactions .


All transactions with someone's income and no cost :

abstract :


For Xiao Zheng , I have all the historical transactions of Yin Cheng , So I will know that he has received two payments 7.0BTC, And didn't pay out , This is the time , Of course Xiao Zheng knows , Yin Cheng has enough money , I can safely exchange my cow for him .

A special deal , Give yourself change , So the output address is your own :

The trading chain :

The basic unit of bitcoin transaction is an unused transaction output , abbreviation UTXO.UTXO yes Can no longer be divided 、 Locked by the owner or recorded in the blockchain and recognized as a monetary unit by the whole network A certain amount of bitcoin currency . The bitcoin network monitors all available data in millions ( Not spent )UTXO. When a user receives bitcoin , The amount is treated as UTXO Record it in the blockchain . such , A user's bitcoin will be treated as UTXO Spread into hundreds of transactions and hundreds of blocks . actually , There is no storage Bitcoin address Or the location of the account balance , Only those locked by the owner 、 Scattered UTXO. A user's bitcoin balance , This concept is created through the bitcoin wallet application A derivative of . Bitcoin wallet scans the blockchain and aggregates all data belonging to the user UTXO Come on Calculate the user's balance . In the world of bitcoin, there are no accounts , And there's no balance , Only those scattered in the blockchain UTXO. One UTXO It can be a Cong Any multiple of . Just like the dollar can be divided into tables Show two decimal places branch equally , Bitcoin can be divided into eight decimal places Cong . Even though UTXO It could be any value , But as long as it's created , It's like it can't be cut in two Half a coin is no longer divisible . If one UTXO More than a transaction , It still Will be consumed as a whole , But at the same time, it will generate a fraction in the transaction . for example , Do you have 20 The currency of the UTXO And want to pay 1 The currency , Then your transaction must consume the whole 20 The currency of the UTXO And produce two outputs : One is paid 1 Bitcoin to the recipient , The other is to pay 19 Bitcoin change to your wallet . In this case , Most bitcoins are paid Yidu will produce change . Imagine , A customer wants to buy 1.5 Yuan's drink . She took out her wallet and tried to get all the coins out of it Find a combination of money and money to make up what she has to pay 1.5 element . If possible , She will choose just Your change ( Such as a 1 Yuan notes and 5 A dime ) Or a combination of small denominations ( such as 3 individual Fifty cents ). If it doesn't work , She will use a large bill , such as 5 Yuan note . If She put too much money , such as 5 element , To the shopkeeper , She'll get 3.5 Yuan change , And put the change Return her wallet for future use . Allied , A bitcoin transaction can have any value , But it must be available from the user UTXO Zhongchuang Build it . Users can no longer put UTXO Further subdivision , Just like you can't tear up a dollar bill and continue to use it as money . The user's wallet application is usually available from the user's wallet UTXO Select multiple available Individuals to piece together a bitcoin amount greater than or equal to a transaction . Just like in real life , Bitcoin applications can use some strategies to meet payment needs : Combine several Small individuals , Calculate the exact change ; Or use an individual greater than the transaction value and make change . the There are these complex 、 Paid by UTXO Completed combination , All are automatically completed by the user's wallet , Not seen by users . Only if you use... Programmatically UTXO To build the original transaction , These are related to You have something to do with . Consumed by transactions UTXO It is called transaction input , Created by the transaction UTXO It's called trading Out . In this way , A certain amount of bitcoin value is transferred between different owners , And in the trading chain Consume and create UTXO. A bitcoin transaction is unlocked by using the owner's signature UTXO, And connect By using the bitcoin address of the new owner to lock and create UTXO.

For output and input chains , There is one exception , It is a special type of transaction , be called coinbase transaction . This is the first transaction in each block . The reason for this transaction is that as a reward for mining, a new bitcoin can be used for payment to Winner The miners .




website :

Want to get the coinage technology and a full set of virtual machine information

Blockchain technology exchange QQ Group :254416566


版权声明:本文为[Yin Cheng]所创,转载请带上原文链接,感谢。