Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.
Sign up to join this communityAnybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
What does 'statically encoded' even mean?
What does 'statically encoded' even mean?
See:
- https://stackoverflow.com/questions/572547/what-does-static-mean-in-c
- https://en.wikipedia.org/wiki/Character_encoding
- https://en.wikipedia.org/wiki/Binary-to-text_encoding
In the case of Bitcoin-Core it is actually coded† in C++ rather than encoded‡ in some encoding like Hex, Base58, etc.
How Is The Genesis Block statically encoded into bitcoin client software?
In src/chainparams.cpp
you can find
static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) { CMutableTransaction txNew; txNew.nVersion = 1; txNew.vin.resize(1); txNew.vout.resize(1); txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); txNew.vout[0].nValue = genesisReward; txNew.vout[0].scriptPubKey = genesisOutputScript; CBlock genesis; genesis.nTime = nTime; genesis.nBits = nBits; genesis.nNonce = nNonce; genesis.nVersion = nVersion; genesis.vtx.push_back(MakeTransactionRef(std::move(txNew))); genesis.hashPrevBlock.SetNull(); genesis.hashMerkleRoot = BlockMerkleRoot(genesis); return genesis; }
And, apparently for each of mainnet, testnet, ... this static function is called like this example (with different parameters for each network)
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
Other Bitcoin clients might code or encode it differently, though with the same resultant value.
e.g.
static const string genesis58 = "mgcrgiW4evD3ZVy2KPcG6GJrbUKSWMU22qPURoShM44B9iZpzAqDN" genesis = Base58.Decode(genesis58)
Then you could more accurately say the genesis block is statically encoded.
† Note that 'coded' means different things in the worlds of cryptography and programming.
‡ Ditto 'encoded'.
You can get bonuses upto $100 FREE BONUS when you:
💰 Install these recommended apps:
💲 SocialGood - 100% Crypto Back on Everyday Shopping
💲 xPortal - The DeFi For The Next Billion
💲 CryptoTab Browser - Lightweight, fast, and ready to mine!
💰 Register on these recommended exchanges:
🟡 Binance🟡 Bitfinex🟡 Bitmart🟡 Bittrex🟡 Bitget
🟡 CoinEx🟡 Crypto.com🟡 Gate.io🟡 Huobi🟡 Kucoin.
Comments