0

What does 'statically encoded' even mean?

1 Answer 1

2

What does 'statically encoded' even mean?

See:

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'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.