Created
July 28, 2018 08:47
-
-
Save suryapratap1/4dab8c85b6cc88c5ad833a707a8a3f53 to your computer and use it in GitHub Desktop.
create litecoin genesis block, the missing code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert(block.hashMerkleRoot == uint256("0x38ca78a781d3c571a681ea2241ffb1e0d89bd1ecd3499f1bf6edeaa8751e7151")); | |
// If genesis block hash does not match, then generate new genesis hash. | |
if (false && block.GetHash() != hashGenesisBlock) | |
{ | |
printf("Searching for genesis block...\n"); | |
// This will figure out a valid hash and Nonce if you're | |
// creating a different genesis block: | |
uint256 hashTarget = CBigNum().SetCompact(block.nBits).getuint256(); | |
uint256 thash; | |
char scratchpad[SCRYPT_SCRATCHPAD_SIZE]; | |
loop | |
{ | |
scrypt_1024_1_1_256_sp_generic(BEGIN(block.nVersion), BEGIN(thash), scratchpad); | |
if (thash <= hashTarget) | |
break; | |
if ((block.nNonce & 0xFFF) == 0) | |
{ | |
printf("nonce %08X: hash = %s (target = %s)\n", block.nNonce, thash.ToString().c_str(), hashTarget.ToString().c_str()); | |
} | |
++block.nNonce; | |
if (block.nNonce == 0) | |
{ | |
printf("NONCE WRAPPED, incrementing time\n"); | |
++block.nTime; | |
} | |
} | |
printf("block.nTime = %u \n", block.nTime); | |
printf("block.nNonce = %u \n", block.nNonce); | |
printf("block.GetHash = %s\n", block.GetHash().ToString().c_str()); | |
} | |
block.print(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment