Bitcoin Forum
July 03, 2024, 04:58:19 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Unable to find Bitcoin supply formula on source code  (Read 90 times)
supermankid (OP)
Jr. Member
*
Offline Offline

Activity: 31
Merit: 12


View Profile
June 16, 2024, 06:21:41 AM
 #1

Hi all ,

I saw this formula on twitter and understood how it limits the supply of bitcoin.
https://ibb.co/2shTcYG
I did searched though some source code but could not find this number for example 210000 anywhere.
Also the hex converted value of this number is not there?( 33450).
Can someone point out where this formula is implemented on code?
tromp
Legendary
*
Offline Offline

Activity: 988
Merit: 1108


View Profile
June 16, 2024, 07:06:11 AM
Last edit: June 16, 2024, 01:15:18 PM by tromp
Merited by pooya87 (4), ABCbits (3), NeuroticFish (2), DaveF (2), HeRetiK (1), FatFork (1)
 #2

The total supply limit (which btw is only 20,999,999.9769 BTC) is not explicit, but implicit [1] from its block subsidy formula as encoded in https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1811-L1822 :

    CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
    {
        int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
        // Force block reward to zero when right shift is undefined.
        if (halvings >= 64)
            return 0;

        CAmount nSubsidy = 50 * COIN;
        // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
        nSubsidy >>= halvings;
        return nSubsidy;
    }

It does have the number 210000 in a comment, albeit with a comma added for legibility...

[1] https://bitcoin.stackexchange.com/questions/38994/will-there-be-21-million-bitcoins-eventually/38998#38998
DaveF
Legendary
*
Offline Offline

Activity: 3528
Merit: 6389


Crypto Swap Exchange


View Profile WWW
June 16, 2024, 12:16:45 PM
 #3

Side note, this is one of those questions that comes up on a somewhat regular basis.

I'm surprised it's not discussed more since it is somewhat important. I have even seen the tinfoil hat wearing nutjobs that don't understand programming argue that since they can't see a line that says maxcoins = 21000000 that we all must be wrong and there is going to be an infinite amount of BTC.

Someone (not me) should probably put together a better (read more dumbed down) explainable way of showing this then what is in the slackexchnage link.

-Dave

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
tromp
Legendary
*
Offline Offline

Activity: 988
Merit: 1108


View Profile
June 16, 2024, 01:17:52 PM
 #4

Someone (not me) should probably put together a better (read more dumbed down) explainable way of showing this then what is in the slackexchnage link.
How about https://unchained.com/blog/bitcoin-source-code-21-million/
supermankid (OP)
Jr. Member
*
Offline Offline

Activity: 31
Merit: 12


View Profile
June 16, 2024, 07:36:47 PM
 #5

Thanks all,

was clear after reading validation.cpp
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!