2

I'm trying to create a testcoin using litecoin. To create genesis block I changed some lines to :

block.nTime = 1390948469; // current time

uint256 hashGenesisBlock("0x"); //I dont now it's true or false

uint256 hash = block.GetHash();
        printf("%s\n", hash.ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0x")); //I dont now it's true or false.
        block.print();
        assert(hash == hashGenesisBlock);

When I build daemon and launch it, I'm getting this error:

litecoind: main.cpp:2788: bool InitBlockIndex(): Assertion `hash == hashGenesisBlock' failed.
Aborted

When I check the ./litecoin debug.log file, I'm seeing the previous hashMerkleRoot and hashGenesisBlock that litecoin uses now. I can't create new hash and merkle root.

3

Create genesis block. Some people get stuck there, it's really easy:

  • find LoadBlockIndex() function, inside, change:
    • paraphrase (pszTimestamp) to any recent news phase.
    • get the latest unix time (do a google), and put in block.nTime.
    • set any nNonce (doesn't really matter), you can change the time/nonce for testnet too, if you want to use it.

After you are done, save it. Now the genesis block will not match the hash check and merkle root check, it doesn't matter.

The first time you run the compiled code (daemon or qt), it will say "assertion failed". Just exit the program, go to config dir (under AppData/Roaming), open the debug.log, get the hash after "block.GetHash() = ", copy and paste it to the beginnig of main.cpp, hashGenesisBlock. Also get the merkle root in the same log file, paste it to the ... position in the following code, in LoadBlockIndex()

 assert(block.hashMerkleRoot == uint256("0x..."));

recompile the code, and genesis block created!

BTW, don't forget to change "txNew.vout[0].nValue = " to the coin per block you defined, it doesn't matter to leave as 50, just be consistent with your coin per block (do this before adjust the hash and m-root, otherwise they will be changed again).

check https://bitcointalk.org/index.php?topic=225690.0 for complete info

  • I changed the pszTimestamp , put the last unix time. After I compiled and started to daemon, I'm getting litecoind: main.cpp:2788: bool InitBlockIndex(): Assertion hash == hashGenesisBlock' failed. Aborted , When I check the debug.log, I'm seeing litecoin's original genesis and merkleroot hashes. What I'm doing wrong ? – ZG-RG Jan 29 '14 at 19:45
  • I tried this but I get ERROR: CheckProofOfWork() : hash doesn't match nBits - any ideas? – Claudiu Feb 28 '14 at 0:57
  • Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently? – creator Feb 17 '18 at 5:36
1

If you want to generate our own unique genesis block you should generate and replace at least the following parameters:

  • nTime (the unix time. Your wallet will display the "No block source available 5 week(s) behind" mentioned if this is 5 weeks old from now)
  • pszTimeStamp (the "timestamp" to "justify" no premining has taken place)
  • hashMerkleRoot (the merkle root based on the coinbase transaction of the block)
  • hashGenesisBlock (the genesis hash itself!)
  • nNonce (the correct nounce which is incremented when searching for the hash that satisfies the target (=difficulty))

The pubkey in the output transaction script can also be changed to a unique value. However, as the genesis block can't be spent anyway the same pubkey can be used as in e.g. Litecoin. Also the nBits should not be changed if you are planning to create a Litecoin clone.

You can use this script to create the values for a scrypt genesisblock: https://github.com/lhartikk/GenesisH0

  • how long it takes on average to get it generated? hours? days? weeks? months> or even more ? – m1k3y3 Oct 25 '17 at 18:33
  • Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently? – creator Feb 17 '18 at 5:36
0

I don't see the code where you actually change the block object's hash. The method hashGenesisBlock() returns a hash, but it's never passed to the block object.

Besides, the first line of your code also has a bug: the current time is 1390959227, not 1390948469. This might also cause a problem.

  • Hello. Now is source changed a lot. And some variables existed doesn't exist, or changed name or new variables come. So how to do this (create new genesis block to make new alt-coin) based on new source currently? – creator Feb 17 '18 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.