Please advise me...
I have been suffering from this problem for almost 4 months now.
I'm trying to clone bitcoin.
I can't change the genesis block.
I used GenesisH0 to create a Genesis block as follows
$ python genesis.py -a SHA256 -z "06/06/2021" -t 1622938707 -n 1158615860
The output was as follows
04ffff001d01040a30362f30362f32303231
algorithm: SHA256
merkle hash: 200f703ffe7f3580d3a38309b207f76f1ab21db7bb4acd97656ba5518d7543ce
pszTimestamp: 06/06/2021
pubkey: 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3 8c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f
time: 1622938707
bits: 0x1d00ffff
Searching for genesis hash..
genesis hash found!
nonce: 1158615860
genesis hash: 000000003a3f2fd0e716571a94390b055c6c6388739845dd7bd66c3de04d2d13
====
Using this data, I pasted in the following.
genesis = CreateGenesisBlock(1622938707, 1158615860, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x000000003a3f2fd0e716571a94390b055c6c6388739845dd7bd66c3de04d2d13"));
assert(genesis.hashMerkleRoot == uint256S("0x200f703ffe7f3580d3a38309b207f76f1ab21db7bb4acd97656ba5518d7543ce"));
====
and
$ make
$ ./testcoind
Then, I get the following error message.
testcoind: chainparams.cpp:129: CMainParams::CMainParams(): Assertion `consensus.hashGenesisBlock == uint256S("0x000000003a3f2fd0e716571a94390b055c6c6388739845dd7bd66c3de04d2d13")' failed.
Aborted (core dumped)
All the code is below.
I would appreciate your advice. Thanks.
======
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
const char* pszTimestamp = "06/06/2021";
const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3 8c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
void CChainParams::UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
{
consensus.vDeployments[d].nStartTime = nStartTime;
consensus.vDeployments[d].nTimeout = nTimeout;
}
class CMainParams : public CChainParams {
public:
CMainParams() {
strNetworkID = "main";
consensus.nSubsidyHalvingInterval = 210000;
consensus.BIP16Height = 0; // 00000000000000ce80a7e057163a4db1d5ad7b20fb6f598c9597b9665c8fb0d4 - April 1, 2012
consensus.BIP34Height = 0;
consensus.BIP34Hash = uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
consensus.BIP65Height = 0; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
consensus.BIP66Height = 0; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 3.5 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 2.5 * 60;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
// Deployment of BIP68, BIP112, and BIP113.
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1462060800; // May 1st, 2016
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1493596800; // May 1st, 2017
// Deployment of SegWit (BIP141, BIP143, and BIP147)
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1479168000; // November 15th, 2016.
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1510704000; // November 15th, 2017.
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x0000000000000000005214481d2d96f898e3d5416e43359c145944a909d242e0"); //506067
/**
* The message start string is designed to be unlikely to occur in normal data.
* The characters are rarely used upper ASCII, not valid as UTF-8, and produce
* a large 32-bit integer with any alignment.
*/
pchMessageStart[0] = 0xcc;
pchMessageStart[1] = 0x54;
pchMessageStart[2] = 0x36;
pchMessageStart[3] = 0x64;
nDefaultPort = 9191;
nPruneAfterHeight = 100000;
genesis = CreateGenesisBlock(1622938707, 1158615860, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x000000003a3f2fd0e716571a94390b055c6c6388739845dd7bd66c3de04d2d13"));
assert(genesis.hashMerkleRoot == uint256S("0x200f703ffe7f3580d3a38309b207f76f1ab21db7bb4acd97656ba5518d7543ce"));
// Note that of those which support the service bits prefix, most only support a subset of
// possible options.
// This is fine at runtime as we'll fall back to using them as a oneshot if they dont support the
// service bits we want, but we should get them updated to support all service bits wanted by any
// release ASAP to avoid it where possible.
vSeeds.emplace_back("80.211.145.197");
vSeeds.emplace_back("80.211.146.33");
base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,48);
base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,80);
base58Prefixes[SECRET_KEY] = std::vector(1,33);
base58Prefixes[EXT_PUBLIC_KEY] = {0x1e, 0x88, 0xB2, 0x1E};
base58Prefixes[EXT_SECRET_KEY] = {0x1e, 0x88, 0xAD, 0xE4};
bech32_hrp = "bc";
vFixedSeeds = std::vector(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
fDefaultConsistencyChecks = false;
fRequireStandard = true;
fMineBlocksOnDemand = false;
checkpointData = {
{
}
};
chainTxData = ChainTxData{
// Data as of block 0000000000000000002d6cca6761c99b3c2e936f9a0e304b7c7651a993f461de (height 506081).
1516903077, // * UNIX timestamp of last known number of transactions
295363220, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
3.5 // * estimated number of transactions per second after that timestamp
};
}
};