This is a seperate discussion from the one about how to generate a Genesis Block here:
https://bitcointalksearch.org/topic/the-genesis-block-187888This thread I want to past the parts of the code that cover the genesis block for discussion of what the code is doing so I can better understand the process. I am using the SmallChange source code who's commit really well shows you all the edits you need to make a new Altcoin, I've been able to make all the changes except the pieces below which I am still trying to understand before I do any major tinkering (all the following snippets are found in main.cpp)...
to see the small change source edits go here:
https://github.com/bfroemel/smallchange/commit/947a0fafd8d033f6f0960c4ff0748f76a3d583261971 1974 pchMessageStart[1] = 0xc1;
1972 1975 pchMessageStart[2] = 0xb7;
1973 1976 pchMessageStart[3] = 0xdc;
1974 - hashGenesisBlock = uint256("0xf5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f");
1977 + hashGenesisBlock = uint256("0xa50faf35e1dddf4a076a907fbcef6d9d1595390cdb1c818a35dae53b67ad0aa8");
In this part I guess it just relates to generating the Gblock and puting in the number there.
1992 -
1993 - // Genesis Block:
1994 - // CBlock(hash=12a765e31ffd4059bada, PoW=0000050c34a64b415b6b, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=97ddfbbae6, nTime=1317972665, nBits=1e0ffff0, nNonce=2084524493, vtx=1)
1995 - // CTransaction(hash=97ddfbbae6, ver=1, vin.size=1, vout.size=1, nLockTime=0)
1996 - // CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d0104404e592054696d65732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997320566973696f6e6172792c2044696573206174203536)
1997 - // CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
1998 - // vMerkleTree: 97ddfbbae6
1999 -
1995 +
1996 + // Genesis block:
1997 + // block.nTime = 1366559428
1998 + // block.nNonce = 2085386442
1999 + // block.GetHash = 384b060671f4a93948e9c168216dadb0ca2fbc54aa11c86b0345b6af1c59b2f5
2000 + // CBlock(hash=384b060671f4a93948e9, PoW=00000951e146b0026411, ver=1,
2001 + // hashPrevBlock=00000000000000000000, hashMerkleRoot=5a2e19825b,
2002 + // nTime=1366559428, nBits=1e0ffff0, nNonce=2085386442, vtx=1)
2003 + // CTransaction(hash=5a2e19825b, ver=1, vin.size=1, vout.size=1, nLockTime=0)
2004 + // CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d010441746f646f3a207265706c616365207769746820736f6d657468696e67207468617420656e7375726573206e6f207072656d696e696e6720746f6f6b20706c616365)
2005 + // CTxOut(error)
2006 + // vMerkleTree: 5a2e19825b
2007 +
I'm assuming there are all the variables, but what is what and would I get them all from running a genesis block generating script.
// Genesis block
- const char* pszTimestamp = "NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56";
+ const char* pszTimestamp = "todo: replace with something that ensures no premining took place";
CTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
- txNew.vout[0].nValue = 50 * COIN;
- txNew.vout[0].scriptPubKey = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
+ txNew.vout[0].nValue = 0;
+ txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG; // a privkey for that 'vanity' pubkey would be interesting ;)
This is the part that confuses me the most, what does the sentence have to do to it. Is the genesis block a numerical version of that phrase and they need to match?
2013 - block.nTime = 1317972665;
2021 + block.nTime = 1366559428;
2014 2022 block.nBits = 0x1e0ffff0;
2015 - block.nNonce = 2084524493;
2023 + block.nNonce = 2085386442;
2016 2024
2017 2025 if (fTestNet)
2018 2026 {
2019 - block.nTime = 1317798646;
2020 - block.nNonce = 385270584;
2027 + block.nTime = 1366559428;
2028 + block.nNonce = 386402991;
2021 2029 }
2022 2030
2023 2031 //// debug print
2024 2032 printf("%s\n", block.GetHash().ToString().c_str());
2025 2033 printf("%s\n", hashGenesisBlock.ToString().c_str());
2026 2034 printf("%s\n", block.hashMerkleRoot.ToString().c_str());
2027 - assert(block.hashMerkleRoot == uint256("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9"));
2035 + assert(block.hashMerkleRoot == uint256("0x5a2e19825b4162f68602039040f1e05d9f924ff00a3aff7327ca6abd6f3279bc"));
2028 2036
here seems to be just more plugging in of the variables from above