Learning Bitcoin - How are new Bitcoins born?
Learning Bitcoin - How are new Bitcoins born?
File: main.cpp |
Repository: fkysly/bitcoin0.1.0
int64 CBlock::GetBlockValue(int64 nFees) const
{
int64 nSubsidy = 50 * COIN;
// Subsidy is cut in half every 4 years
nSubsidy >>= (nBestHeight / 210000);
return nSubsidy + nFees;
}
The Mining Factory
Before we understand how money is sent, we must understand how it is born. Bitcoin doesn't have a central bank; instead, it has Miners. Imagine these miners as Security Guards who participate in a global digital lottery every 10 minutes. The guard who wins the lottery gets the right to secure the next "Block" of transactions and receives a "Birth Reward" (Subsidy) for their hard work.
Satoshi chose a 10-minute rule to ensure that "Gossip" about new blocks has enough time to travel across the entire planet’s internet cables. If it were faster, the network might get confused and split into different versions!
Let us breakdown
This line is the "Address" of the work. Let's look at the pieces:
- int64: The giant "Water Tank" box that can hold numbers as big as 9 quintillion.
- CBlock ::: This tells the computer to look inside the "Bitcoin Box" category for this rule.
- GetBlockValue: The specific name of this job (calculating the reward).
- (int64 nFees): This is an input. It allows other parts of the code to "hand over" the transaction tips to this function.
- const: A security lock. It ensures this function can only read data, it cannot accidentally change anything it isn't supposed to.
This is the Starting Salary. In 2009, Satoshi set the reward at 50 BTC. Why 50? Because the math of starting at 50 and halving every 4 years leads perfectly to a total supply of 21 Million. It is the "magic number" that defines Bitcoin's scarcity.
Imagine a giant Lego Tower. nBestHeight is the number of
blocks in that tower today. Satoshi calculated that 210,000 blocks are found roughly every 4 years.
This part of the code acts as a Timer—every time the tower grows by another 210,000 blocks,
it signals the system to cut the reward.
This symbol is a computer genius's shortcut for "Divide by 2." Every 4 years, it takes the reward and cuts it exactly in half. This is the Halving. In 2009 it was 50, then 25, then 12.5... eventually, this cutter will reduce the reward to zero crumbs!
The word return is like a Waiter handing you the final
bill. It adds the "Base Salary" (the 50 BTC subsidy) and the "Tips" from users (the
nFees). This ensures that even when the subsidy hits zero in the future, the security
guards still get paid from the tips!
Why this matters
This simple function is the "Engine of Scarcity." Unlike normal money that central banks can print infinitely, Bitcoin's "Birth rate" is locked in math. We know exactly how many coins will exist at any moment in time. This transparency and predictability are the reasons why Bitcoin is often called Digital Gold.
Support the Mission & Keep Learning
Original Source: main.cpp (Line 675)