Created
June 28, 2018 13:21
-
-
Save omarbaruzzo/a86a65d890ed823013315ea2d3727c2d to your computer and use it in GitHub Desktop.
GenesisCalculator - code to be included in chainparams.cpp to calculate the genesis block, nnonce, merkle root etc.
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
#include "arith_uint256.h"//Mod. | |
//---------------------------------------------------------------------------------------------------------- | |
//Mod. | |
/* | |
// calcolo del Blocco Genesi | |
// Resettiamo il valore del blocco | |
consensus.hashGenesisBlock = uint256S("0x"); | |
std::cout << std::string("Iniziamo a calcolare il blocco:\n"); | |
if (true && (genesis.GetHash() != consensus.hashGenesisBlock)) { | |
LogPrintf("Calcolo del blocco genesi:\n"); | |
arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits); | |
uint256 hash; | |
genesis.nNonce = 0; | |
while (UintToArith256(genesis.GetHash()) > hashTarget) | |
{ | |
++genesis.nNonce; | |
if (genesis.nNonce == 0) | |
{ | |
LogPrintf("NONCE WRAPPED, tempo di incremento"); | |
std::cout << std::string("NONCE WRAPPED, tempo di incremento:\n"); | |
++genesis.nTime; | |
} | |
if (genesis.nNonce % 10000 == 0) | |
{ | |
LogPrintf("Mainnet: nonce %08u: hash = %s \n", genesis.nNonce, genesis.GetHash().ToString().c_str()); | |
//std::cout << strNetworkID << " nonce: " << genesis.nNonce << " time: " << genesis.nTime << " hash: " << genesis.GetHash().ToString().c_str() << "\n"; | |
} | |
} | |
std::cout << "Mainnet ---\n"; | |
std::cout << " nonce: " << genesis.nNonce << "\n"; | |
std::cout << " time: " << genesis.nTime << "\n"; | |
std::cout << " hash: " << genesis.GetHash().ToString().c_str() << "\n"; | |
std::cout << " merklehash: " << genesis.hashMerkleRoot.ToString().c_str() << "\n"; | |
// Mainnet --- nonce: 296277 time: 1390095618 hash: 000000bdd771b14e5a031806292305e563956ce2584278de414d9965f6ab54b0 | |
} | |
// std::cout << std::string("Finished calculating Mainnet Genesis Block:\n"); | |
LogPrintf("Finished calculating Mainnet Genesis Block:\n"); | |
// std::cout << "Mainnet ---\n"; | |
// std::cout << " nonce: " << genesis.nNonce << "\n"; | |
LogPrintf("nonce: %s\n",genesis.nNonce); | |
// std::cout << " time: " << genesis.nTime << "\n"; | |
LogPrintf("time: %s\n", genesis.nTime); | |
// std::cout << " hash: " << genesis.GetHash().ToString().c_str() << "\n"; | |
LogPrintf("hash: %s\n", genesis.GetHash().ToString().c_str()); | |
// std::cout << " merklehash: " << genesis.hashMerkleRoot.ToString().c_str() << "\n"; | |
LogPrintf("merkle hash: %s\n",genesis.hashMerkleRoot.ToString().c_str()); | |
//---------------------------------------------------------------------------------------------------------- | |
*/ | |
LogPrintf("Merkle Root: %s\n", genesis.hashMerkleRoot.ToString().c_str());//Mod. | |
LogPrintf("Blocco Genesi: %s\n", consensus.hashGenesisBlock.ToString().c_str());//Mod. |
scrypt? or sha256?
Dash = X11 but should work with most Bitcoin clones.
any idea if this will work with x16r (from ravencoin)?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
code to be included in chainparams.cpp to calculate the genesis block, nnonce, merkle root etc.
Baruzzo Omar Developing