I followed this medium link to create a coin just like bitcoin . https://medium.com/@jordan.baczuk/how-to-fork-bitcoin-c39139506443
Based on this tutorial i update DEFAULT_MAX_TIP_AGE
to int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE * 4000;
but it does not work, i did not able to mine block but when i add -maxtipage=432000000
to my command line daemon then mining work i was able to mine genesis block . but then i thought it would be better if i can create my own geneisis block.
so i followed this link : How can I create a new Genesis Block?
I made changes to pszTimestamp
, nTime
and nNonce
, hashGenesisBlock
and hashMerkleRoot
.
I was able to run the daemon without any assert
issue . First i got this error
ERROR: ReadBlockFromDisk: Errors in block header at CBlockDiskPos(nFile=0, nPos=8) 2018-11-08T10:12:47Z *** Failed to read block
Then after running command line daemon with -reindex
. the previous error vanishes but got a new error
ERROR: AcceptBlock: high-hash, proof of work failed (code 16)
How can i resolve this issue
EDIT: Based on the suggestion given by @JBaczuk . I used genesisgen to generate block information
https://github.com/liveblockchain/genesisgen
CMD Syntax:
./genesis [options] <pubkey> "<timestamp>" <nBits> <startNonce> <unixtime>
My CMD:
./genesis 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches" 486604799 2083236893 1541690605
OUTPUT:
nBits: 0x1d00ffff
startNonce: 2083236893
unixtime: 1541690605
Coinbase: 04ffff001d01044c504e4454562030382f4e6f762f3230313820496e6469612057616e747320546f204c6f63616c6c79204d616e75666163747572652c204578706f72742042756c6c657420547261696e20436f6163686573
PubkeyScript: 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac
Merkle Hash: 94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d
Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494
Generating block...
124397 Hashes/s, Nonce 20632283897
Block found!
Hash: 000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672
Nonce: 2063257030
Unix time: 1541690608
Changes in code:
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
const char* pszTimestamp = "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches";
const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
...... ...... ......
genesis = CreateGenesisBlock(1541690608, 2063257030, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672"));
assert(genesis.hashMerkleRoot == uint256S("0x94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d"));
I got this assertion error:
chainparams.cpp:125: CMainParams::CMainParams(): Assertion `genesis.hashMerkleRoot == uint256S("0x94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d")' failed.
Aborted (core dumped)