mining concept – How Is The Genesis Block statically encoded into bitcoin consumer software program?


What does ‘statically encoded’ even imply?

See:

Within the case of Bitcoin-Core it’s really coded† in C++ moderately than encoded‡ in some encoding like Hex, Base58, and many others.


How Is The Genesis Block statically encoded into bitcoin consumer software program?

In src/chainparams.cpp yow will discover

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::transfer(txNew)));
    genesis.hashPrevBlock.SetNull();
    genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
    return genesis;
}

And, apparently for every of mainnet, testnet, … this static perform is named like this instance (with totally different parameters for every community)

      genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);

Different Bitcoin shoppers may code or encode it otherwise, although with the identical resultant worth.

e.g.

static const string genesis58 = "mgcrgiW4evD3ZVy2KPcG6GJrbUKSWMU22qPURoShM44B9iZpzAqDN"
genesis = Base58.Decode(genesis58)

Then you possibly can extra precisely say the genesis block is statically encoded.


† Word that ‘coded’ means various things within the worlds of cryptography and programming.
‡ Ditto ‘encoded’.

Leave a Reply

Your email address will not be published.