Bitcoin and blockchain

in blockchain •  4 years ago 

Content

In the eyes of many people, Bitcoin is an electronic currency, but in fact the meaning that Bitcoin can carry far exceeds the scope of money. The mode of operation of Bitcoin is groundbreaking and inspiring. To understand the essence of Bitcoin, it may be easier to understand Bitcoin as a small society without centralized power.

This article attempts to describe the operating mechanism of Bitcoin from the perspective of an incomplete programmer and an incomplete "non-programmer". The goal is to enable non-programmers to understand the principles of Bitcoin, and programmers to advance on the basis of understanding the principles.

Bitcoin network

The operation of Bitcoin relies on the network, mainly the Internet. Bitcoin relies on the network, but it is a network in itself. Bitcoin is an Internet-based application, which can be roughly understood as the relationship between fax machines and telephone lines.

The Bitcoin network consists of many "nodes". Each node is a computer or other computing device. Or to be more precise, a node is a "computer with Bitcoin software installed." Any home computer with Bitcoin software installed and running can join the Bitcoin network and become a Bitcoin network node.

Every node in the Bitcoin network is equal. There is no privileged class, no central server.

In computer terms, this kind of network without a center is called a P2P (Peer-to-Peer) network, which is a point-to-point network. Because the P2P network does not have a central server, the sending and receiving of data can be completed by both parties of the communication, without the participation of a third party. All activities in the P2P network are completed by the hard "work" and mutual communication of these nodes.

The only topic of communication between network nodes is "Bitcoin". Every node is watching the latest news about Bitcoin in the entire network at any time, monitoring every transaction of Bitcoin. "Bitcoin" "circulates" in the P2P network through communication between nodes.

Since the P2P network does not have a central server, the circulation of Bitcoin cannot pass through the "central exchange." It can only be "word of mouth" through independent nodes. Therefore, Bitcoin transactions are completed on the Internet in the way of "one pass ten, ten pass a hundred".

Network node

A Bitcoin network node is a computer with Bitcoin software installed. The reason why it is called "Bitcoin software" instead of "Bitcoin client" is because every node in the Bitcoin network is equal. There is no server in the Bitcoin network, so it is not easy to call it a "client". The participating computers are all installed with the same (or similar) Bitcoin software, so that each node runs strictly in accordance with the same rules.

Bitcoin software is an open source project, anyone can easily get Bitcoin software: https://bitcoin.org/en/choose-your-wallet.

Developers can also easily get the source code of Bitcoin software from github:

Although open source software can be modified by everyone, this does not mean it is insecure. In fact, once you understand the operating mechanism of Bitcoin, you will understand that any illegal modification of the source code will be rejected by the Bitcoin network lock. All variants of Bitcoin software must comply with the same Bitcoin rules in order to be accepted by other nodes on the network.

Since this article attempts to explain Bitcoin from a non-technical (OK, or very little technical) perspective, there will be fewer mentions of the programmer’s perspective and the implementation technology of Bitcoin.

Bitcoin software comes in many forms, ranging from lightweight software with only partial functions to full-featured software. Select "Bitcoin Core" on the download page, it is a complete software, and the Bitcoin APP running on the mobile phone is a lightweight software. According to the division of labor and roles of nodes, different forms of software can be selected for download.

The daily work of a network node can be roughly composed of several parts:

Responsible for delivering messages (routing)
Be responsible for work (miners)
Be responsible for managing your own Bitcoin (wallet)

For the above three responsibilities, in addition to the first one is necessary, the network node can choose to do or not to do the other two. Different forms of Bitcoin software implement some or all of the above three. For example, the desktop version of "Bitcoin Core" implements all the functions; the mobile version of the software may only implement the "wallet" and "routing" functions.

Bitcoin

Bitcoin is a digital currency circulating on the Bitcoin network. The entire Bitcoin network revolves around the production and circulation of Bitcoin. With the joint collaboration of Bitcoin nodes, the Bitcoin ecosystem runs prosperously and steadily like a well-ordered small society, and continues to grow day by day.

So what exactly is Bitcoin?

All digital currencies are virtual, they have no physical entities, and Bitcoin is no exception. The physical existence of digital currency is nothing more than a string of numbers on a computer hard disk. As we can see later, this is not a random string of ordinary numbers, but a string with source, destination, beginning and end, evidence, traceability, difficult to forge, difficult to steal, and to maintain the entire system. A number essential for completeness.

Bitcoin's life cycle

Since Bitcoin is just a string of numbers, how did it come about?

Where are Bitcoins stored?

How to trade Bitcoin?

Let's take a look at the creation of Bitcoin first. In one sentence: Bitcoin is produced by the aforementioned miner node through the activity of "mining".

In the Bitcoin network, there are a large number of "miner" nodes. These miner nodes are constantly doing a kind of repetitive labor "mining". "Mining" is a very heavy and uninspiring physical task. This kind of physical work is not only onerous, but also has a low success rate. The success rate of mining is based on a certain probability, and there must be a reward for doing the work. All the miner nodes in the entire Bitcoin network work together, and on average, only one lucky miner node can successfully mine the mine every 10 minutes.

When a miner digs into a mine, he digs Bitcoin; Bitcoin is a reward for the hard work of the miner. Every time the bitcoin is successfully mined, only the only miner who mined the mine will be rewarded.

Mining

The total amount of bitcoin is fixed, and there are a total of 21 million bitcoins waiting to be mined. And over time, the rewards for mining will gradually decrease.

Specifically, every time 210,000 mines are mined, the reward will be halved. Since an average miner successfully digs a mine every 10 minutes, it will dig 210,000 times every 4 years. So about every 4 years, the output of mining will be halved.

The Bitcoin network has been online since January 2009. At that time, the reward for each successful mining was 50 Bitcoins. In November 2012, after the 210,000th mine was mined, the reward for mining was reduced from 50 to 25 each time. In July 2016, the reward was halved again to 12.5 bitcoins.

The time interval between the two reward halvings is not strictly 4 years. But this is not surprising, because Bitcoin mining is based on a certain probability, and there is no absolute time control. Therefore, the output once every 10 minutes is only a mathematical "expected value", not an absolute value. So time deviation is inevitable, but according to the principle of probability, the average value of long-term statistics will meet expectations.

So here comes the question: then every time a miner successfully digs a mine, who will give the miner a reward? Who produced these bitcoins?

The answer is: the miners produced bitcoins themselves and sent them to themselves.

You know, the Bitcoin network is a network without a central organization. All nodes run the same program, and no node has privileges. There is no money printing agency like a central bank. Therefore, the order of the Bitcoin network is jointly maintained by the network nodes. Miners’ work rewards can only be done by the miners themselves.

by! Does this work? If you can make coins and give yourself prizes, wouldn’t it be a mess for everyone to do this?

Rest assured, other nodes on the Bitcoin network are monitoring this lucky miner. Miners must strictly follow the rules to generate their own rewards. If they cheat, they will be immediately discovered by other miners and jointly resist the fruits of his labor. In this way, his labor and his luck were wasted.

In addition to the newly generated bitcoin, the output of mining also has a "tip" income. Because the process of mining is actually a process of competing for the "right to keep accounts". In addition to being rewarded with new bitcoins, the winning miner is also responsible for accounting for all transactions that occurred during this period (approximately 10 minutes). Every Bitcoin transaction comes with a certain amount of transaction fees, which are also owned by the miner who wins the mining.

Bitcoin address

After Bitcoin was produced, the winning miners gave the new Bitcoin its own "label", indicating that the money belonged to itself. After that, only this miner can use the money. Until he traded the money to another person.

This special tag is called "Bitcoin Address". Bitcoin addresses are like bank account numbers, used to collect money. The funds in a Bitcoin address can only be used by those who hold the key to that address.

The Bitcoin address is a long string of characters that looks like this: "1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA". The principle of cryptography is implicit in the Bitcoin address, and we can explain it in detail later. Now only need to know that it is a receiving address.

Transaction

As mentioned earlier, Bitcoin is a string of numbers. So what does it look like? How do you use numbers to represent a bitcoin in a computer? Is a bitcoin corresponding to a number? Or what?

In fact, there are no numbers in the network that directly correspond to Bitcoin. In the Bitcoin address (account), there is also no "Bitcoin balance" data. The production and circulation of Bitcoin are all recorded in the form of "transactions". The new bitcoins mined by miners are not accounted for by simply increasing the balance of their address, but by creating a "transaction".

The transaction records the flow of Bitcoin in the system. Whenever a miner digs a sum of money, or someone spends a sum of money, a transaction record is generated. The content of each transaction record is approximately "How much is this money? Where does it come from, and where does it go?". Every transaction must have a source and destination. This is called the "input and output" of the transaction.

After miners dig new bitcoins, they will create a transaction, and then assign the output of the transaction to their bitcoin address. This is equivalent to adding a new bitcoin to your address.

Let's take the first transaction in the history of Bitcoin as an example. This transaction records the first 50 bitcoins mined by a miner and is output to the bitcoin address of the miner who mined the bitcoin.

image.png

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!