Read article bitcoin primary knowledge — account
Bitcoin as an excellent and the most successful block chain system, very worthy of our research and learning. Through the front of the article, I believe we already know bitcoin is a maintenance of the books together. Then, the specific books is how to work?
In general, need to have an account, we begin to charge.
Bitcoin uses a mode called UXTO to replace the traditional account. UXTO is the abbreviation of UnspentTransactionOutput, is a genius inventor Nakamoto bitcoin “. Essentially, UXTO is running account. To understand a little bit of accounting, corporate accounting have seen students know, now most of the accounting system is a method called “double entry bookkeeping”, divided into account debits and credits, each occurrence of a business should be enrolled more than two subjects.
In simple terms, the Alice transfer to Bob1 dollars, the use of debit and credit method to produce at least two accounts, Alice accounts for a decrease of $1, an increase of $1 Bob account. This accounting method has numerous benefits in the audit of enterprise management and enterprise, need not be detailed here. But this accounting method also has a big disadvantage, is prone to error and error of accounting bookkeeping. A transaction needs to register more than two accounts, the essence of the record is the outcome of the transaction, the transaction itself “rather than””.
If a programmer to design based on “double entry bookkeeping” books, records in database is each account and balance changes. In the database system, we need a series of additional rules, to ensure that the transaction successfully. In the Alice Bob to transfer $1 in operating system, first of all need to check the Alice account balance is greater than or equal to $1, then check the account of Bob address is legal, and finally the Alice account by 1, plus 1 Bob account.
The process is not very complicated? In fact, the accounting work is busy, because every day they put the transaction split into different subjects to record. Different accounting transactions of different understanding, may record the subjects (of course is not the same in the transfer system simple, this problem does not exist, so have the differences in accounting).
Nakamoto did not use accounting scheme of this complex, instead of using a tracking bitcoin journal recording method — UXTO. In essence, is the only record of the transaction itself, and does not record the transaction results. From the perspective of financial system, this way is “clearing separation” means. Block chain system only handles all transactions, and the need to view the balance of liquidation, and other information, at the discretion of the blockchain node.
Tell a story to understand UXTO:
Gold Tom dug up a piece of gold, weight is 100 grams, so the first recorded a record 100 grams of gold mining, into the pocket of Tom. Then Tom took the piece of gold to Alice, so the system records a transaction – 100 grams of gold transferred from the Tom to the Alice pocket pocket. Later, Alice also put the gold into two halves, sold to Bob and Charlie, so the system also recorded a trade – 100 grams of gold from the Alice out of pocket, were transferred to Bob50 grams and Charlie50 grams. It looks like this is the record table:
The tree for programmers the most familiar to describe possible more clearly:
Each root node is a CoinBase (mining, transaction) is every bitcoin origin. Then as the transaction changes, the tree growing, each leaf node is a UXTO—-UnspentTransactionOutput—- not spend trading output. Strictly speaking, the bitcoin system is not a tree, but a single map. Along with the complexity of the transaction, the middle branches are constantly staggered, but does not prevent us from using the tree structure to understand it.
UXTO bitcoin followed two rules:
1, in addition to CoinBase (mining transaction), all sources of funding must come from the front of one or several transactions UXTO;
2 of the total input, any transaction must be equal to the total output, both sides of the equation must be trimmed. (in the bitcoin system, generally less than the input output, the difference is the transfer fee to all miners.)
This is not a simple transaction records much? The fewer rules, the system is prone to problems. Bitcoin is running for so many years, it has withstood the test of time.
The benefits of UXTO mode is the biggest, it faithfully records the transaction. Our world is with the flow of time, the transaction occurred a sum, block chain system bitcoin a faithful record of the world happened, cannot rollback, cannot be deleted. As long as the transaction records accurately, clearly, then everyone would go wrong liquidation results.
Therefore, the “trade” is the core of bitcoin block chain system, “record deal” is the design principle of block chain system, is also one of the core block chain design.