Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save omarbaruzzo/a86a65d890ed823013315ea2d3727c2d to your computer and use it in GitHub Desktop.
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.
#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.
@omarbaruzzo
Copy link
Author

code to be included in chainparams.cpp to calculate the genesis block, nnonce, merkle root etc.

Baruzzo Omar Developing

@ricardofriba
Copy link

scrypt? or sha256?

@NicolasChoukroun
Copy link

Dash = X11 but should work with most Bitcoin clones.

@j4ys0n
Copy link

j4ys0n commented Dec 30, 2018

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