A transaction is bitcoins from one address, transferred to another address. Since all bitcoin transaction records are public, it is possible to find out how many bitcoins an address owns. Therefore, it can be easily verified whether the payer has enough bitcoins to complete the transaction.
The problem is how to prevent others from falsely reporting transactions in your name. For example, someone declares a transaction: address A pays address B 10 bitcoins. How do I know that the declaration is true and that the declarant is the owner of address A?
The Bitcoin protocol stipulates that when declaring a transaction, in addition to the transaction amount, the party transferring the Bitcoin must also provide the following data.
Hash of last transaction (where did you get these bitcoins)
The addresses of both parties to this transaction
Payer’s public key
The digital signature generated by the payer’s private key
Verifying that the transaction is genuine requires three steps.
The first step is to find the last transaction and confirm the Bitcoin source of the payer.
The second step is to calculate the fingerprint of the payer’s public key and confirm that it is consistent with the payer’s address, so as to ensure that the public key is true.
The third step is to use the public key to unlock the digital signature to ensure the authenticity of the private key.
After the above three steps, it can be determined that the transaction is real.
After confirming the authenticity of the transaction, the transaction is not completed. The transaction data must be written into the database before it is established, and the other party can actually receive the money.
Bitcoin uses a special database called a blockchain .
First, all transaction data is sent to the miners. Miners are responsible for writing these transactions into the blockchain.
According to the Bitcoin protocol, the maximum size of a block is 1MB, and a transaction is about 500 bytes, so a block can contain up to more than 2,000 transactions. Miners are responsible for packing these 2,000+ transactions together into a block, and then calculating the hash of the block.
The process of computing hashes is called mining, and it requires a lot of computation. There is also competition among miners, whoever calculates the hash first will be the first to add a new block to the blockchain and enjoy the full benefits of this block, while other miners will get nothing.
Once a transaction is written into the blockchain, it cannot be reversed. A concept needs to be established here: Bitcoins are not stored in wallets or other places, but only exist on the blockchain. The blockchain records every transaction you participate in, how much bitcoin you get, and how much you pay, so you can figure out how much assets you own.
The confirmation of the transaction is inseparable from the miners. Why would anyone want to be a miner?
The Bitcoin protocol stipulates that miners who mine new blocks will be rewarded with 50 bitcoins at the beginning (2008), then halved every 4 years, and currently (2018) is 12.5 bitcoins. This is also the supply increase mechanism of Bitcoin, and the new Bitcoins in circulation are born in this way.
As you may have seen, the reward is halved every 4 years. Since Bitcoin can be divided into eight decimal places, by 2140, miners will not receive any reward and the number of Bitcoins will stop increasing. At this time, the income of miners depends entirely on transaction fees.
The so-called transaction fee is that miners can take a commission from each transaction, and the specific amount is voluntarily determined by the payer. You can pay nothing and don’t give miners a penny, but in that case, your transaction will be unprocessed, and it will not be able to be written into the blockchain and confirmed. Miners always prioritize transactions with the highest fees.
At present, due to the sharp increase in the number of transactions, the handling fee has risen, and the total handling fee of more than 2,000 transactions in a block can reach 3 to 10 bitcoins. If your fee is low, it is likely that a week has passed and the transaction has not been confirmed.
The reward for a block is 12.5 bitcoins, plus the handling fee, the income is quite considerable. According to the , it can reach 1 million to 2 million yuan. Think about it, if you are lucky, you can mine a block in a few minutes, and get such a large amount of money, no wonder people are rushing to mining.