why did assert fail when creating my own genesis block?

-1

1

I am trying to create my own genesis block using the bitcoin source code but my new hashes are not being accepted by the assert statements.

Step 1:

I have changed the pszTimestamp variable in chainparams.cpp to generate my own genesis hash.

I have added into the code some print statements to check the genesis hash and merkle root as they are generated from my new pszTimestamp.

The hashes I have generated are:

MERKLE ROOT:9f46bcd8a56be2b6b022acbcc859b201534c21801b1b73685a69de17ad37665e

GENESIS HASH:cc45935bfeb12faacc8ab2797d2f5507f7eef8a44c597f3622c704cc0af8a648

Step 2:

I have changed the assert statements below to assert the new hashes on line 131 and line 230 of chainparams.cpp

The Genesis Block assert(consensus.hashGenesisBlock==uint256S("0xcc45935bfeb12faacc8ab2797d2f5507f7eef8a44c597f3622c704cc0af8a648"));

The Merkle Root assert(genesis.hashMerkleRoot==int256S("0x9f46bcd8a56be2b6b022acbcc859b201534c1801b1b73685a69de17ad37665e"));

However...

These assert statements still fail. Why?

I have included the error message below:

bitcoin-qt: chainparams.cpp:230: CTestNetParams::CTestNetParams(): Assertion `consensus.hashGenesisBlock == uint256S("0xcc45935bfeb12faacc8ab2797d2f5507f7eef8a44c597f3622c704cc0af8a648")' failed. Aborted (core dumped)

Oscar Chambers

Posted 2017-11-14T04:02:26.120

Reputation: 215

The question has over 1000 views now so obviously others are facing the issue... – Oscar Chambers – 2020-03-28T07:57:51.297

Downvoted. We have many questions regarding programming issues when creating a new altcoin. I don't believe such questions benefit a general audience, and this is a Q&A site, not a place for support. Furthermore, as a learning experience, contributing to an existing project is far more valuable. – Pieter Wuille – 2018-11-15T21:48:42.213

Answers

1

The problem is that you changed the testnet parameters too, not just the mainnet parameters. However I doubt that you regenerated the testnet genesis block, or if you did, you did not set the assert correctly. You set the assert in the testnet chain parameters to be the mainnet genesis block hash and merkle root. But that is obviously wrong; testnet is not the same as mainnet. To fix this, you should either revert the change, or generate a new testnet genesis block and set those asserts accordingly.

Andrew Chow

Posted 2017-11-14T04:02:26.120

Reputation: 50 267

1If I revert the testnet params back to their original values. I still get an assert error bitcoin-qt: chainparams.cpp:227: CTestNetParams::CTestNetParams(): Assertionconsensus.hashGenesisBlock == uint256S("0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943")' failed. Aborted (core dumped)` – Oscar Chambers – 2017-11-14T06:33:16.513