MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CreateGenesisBlock

Function CreateGenesisBlock

src/kernel/chainparams.cpp:37–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35using namespace util::hex_literals;
36
37static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
38{
39 CMutableTransaction txNew;
40 txNew.version = 1;
41 txNew.vin.resize(1);
42 txNew.vout.resize(1);
43 txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
44 txNew.vout[0].nValue = genesisReward;
45 txNew.vout[0].scriptPubKey = genesisOutputScript;
46
47 CBlock genesis;
48 genesis.nTime = nTime;
49 genesis.nBits = nBits;
50 genesis.nNonce = nNonce;
51 genesis.nVersion = nVersion;
52 genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
53 genesis.hashPrevBlock.SetNull();
54 genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
55 return genesis;
56}
57
58/**
59 * Build the genesis block. Note that the output of its generation

Callers 5

CMainParamsMethod · 0.85
CTestNetParamsMethod · 0.85
CTestNet4ParamsMethod · 0.85
SigNetParamsMethod · 0.85
CRegTestParamsMethod · 0.85

Calls 7

MakeTransactionRefFunction · 0.85
BlockMerkleRootFunction · 0.85
CScriptClass · 0.70
CScriptNumClass · 0.50
resizeMethod · 0.45
push_backMethod · 0.45
SetNullMethod · 0.45

Tested by

no test coverage detected