Genesis hash finder và fork Qtum

Fork Qtum tạo chain mới https://www.youtube.com/watch?v=5rqiGruTe4E Như bitcoin đã biết nó mã hóa chuẩn SHA256, Litecoin là SCRYPT hay Dash là X11.. thì ta đã có các công cụ tìm genesis hash https://github.com/vuicash/node-genesis-block GitHub – vuicash/node-genesis-block: Create Genesis Block for Bitcoin, Litcoin, Dash, X11, X13, X15, X17, Geek, Quark, Keccak, Qubit, NeoScrypt, Scrypt… Create Genesis

Fork Qtum tạo chain mới

https://www.youtube.com/watch?v=5rqiGruTe4E

Như bitcoin đã biết nó mã hóa chuẩn SHA256,
Litecoin là SCRYPT
hay Dash là X11.. thì ta đã có các công cụ tìm genesis hash

https://github.com/vuicash/node-genesis-block

GitHub – vuicash/node-genesis-block: Create Genesis Block for Bitcoin, Litcoin, Dash, X11, X13, X15, X17, Geek, Quark, Keccak, Qubit, NeoScrypt, Scrypt…
Create Genesis Block for Bitcoin, Litcoin, Dash, X11, X13, X15, X17, Geek, Quark, Keccak, Qubit, NeoScrypt, Scrypt… – GitHub – vuicash/node-genesis-block: Create Genesis Block for Bitcoin, Litcoi…
github.com

https://github.com/vuicash/GenesisH0

GitHub – vuicash/GenesisH0: SHA256/scrypt/X11/X13/X15 genesis blocks for virtual currencies
SHA256/scrypt/X11/X13/X15 genesis blocks for virtual currencies – GitHub – vuicash/GenesisH0: SHA256/scrypt/X11/X13/X15 genesis blocks for virtual currencies
github.com

https://github.com/vuicash/generate-genesis

GitHub – vuicash/generate-genesis: A Bitcoin-clone (altcoin) Genesis block generator.
A Bitcoin-clone (altcoin) Genesis block generator. – GitHub – vuicash/generate-genesis: A Bitcoin-clone (altcoin) Genesis block generator.
github.com

Nhưng một số coin nó không tiết lộ nên phải Debug
Các bạn nên build từ bản cũ hơn của Qtum để tìm genesis hash cho nhanh
Nó mất thời gian ở công đoạn chạy lệnh “make” mất tầm 30 phút
Sau đó nâng cấp dần coin của bạn
Qtum là một dự án khai thác trước
Bạn sẽ tìm 5000 block đầu tiên rồi hãy tiến hành nâng cấp coin tạo checkpoint ở block thứ 5000 sau đó mới public

Cách Debug

https://github.com/boxaltcoin/vuicoin/blob/master/qtum.txt
############################### Change magic key make new chain #################################

git clone https://github.com/qtumproject/qtum --recursive

consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");// Start

https://en.bitcoin.it/wiki/List_of_address_prefixes

48 	L 

70-71 	V 
132-133 	v 



############################## Make publickey ##################################

openssl ecparam -genkey -name secp256k1 -out genesiscoinbase.pem

openssl ec -in genesiscoinbase.pem -text > genesiscoinbase.hex

################################################################

date +%s


############################## Genesis hash Debug ##################################


File  src/chainparams.cpp

Add before 

/**
 * Main network
 */
#######################
static void MineGenesis(CBlockHeader& genesisBlock, const uint256& powLimit, bool noProduction)
{
    if(noProduction)
        genesisBlock.nTime = std::time(0);
    genesisBlock.nNonce = 0;

    LogPrintf("NOTE: Genesis nTime = %u n", genesisBlock.nTime);
    LogPrintf("WARN: Genesis nNonce (BLANK!) = %u n", genesisBlock.nNonce);

    arith_uint256 besthash;
    memset(&besthash,0xFF,32);
    arith_uint256 hashTarget = UintToArith256(powLimit);
    LogPrintf("Target: %sn", hashTarget.GetHex().c_str());
    arith_uint256 newhash = UintToArith256(genesisBlock.GetHash());
    while (newhash > hashTarget) {
        genesisBlock.nNonce++;
        if (genesisBlock.nNonce == 0) {
            LogPrintf("NONCE WRAPPED, incrementing timen");
            ++genesisBlock.nTime;
        }
        // If nothing found after trying for a while, print status
        if ((genesisBlock.nNonce & 0xfff) == 0)
            LogPrintf("nonce %08X: hash = %s (target = %s)n",
                   genesisBlock.nNonce, newhash.ToString().c_str(),
                   hashTarget.ToString().c_str());

        if(newhash < besthash) {
            besthash = newhash;
            LogPrintf("New best: %sn", newhash.GetHex().c_str());
        }
        newhash = UintToArith256(genesisBlock.GetHash());
    }
    LogPrintf("Genesis nTime = %u n", genesisBlock.nTime);
    LogPrintf("Genesis nNonce = %u n", genesisBlock.nNonce);
    LogPrintf("Genesis nBits: %08xn", genesisBlock.nBits);
    LogPrintf("Genesis Hash = %sn", newhash.ToString().c_str());
    LogPrintf("Genesis hashStateRoot = %sn", genesisBlock.hashStateRoot.ToString().c_str());
    LogPrintf("Genesis Hash Merkle Root = %sn", genesisBlock.hashMerkleRoot.ToString().c_str());
}
#######################

####################### 1. Mainnet #######################

Find and replace
#######################
        genesis = CreateGenesisBlock(1504695029, 8026361, 0x1f00ffff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x000075aef83cf2853580f8ae8ce6f8c3096cfa21d98334d6e3f95e5582ed986c"));
        assert(genesis.hashMerkleRoot == uint256S("0xed34050eb5909ee535fcb07af292ea55f3d2f291187617b44d3282231405b96d"));
#######################
with
#######################
//Debug Mainnet
        startNewChain = true;

        genesis = CreateGenesisBlock(1506211200, 0, 0x1f00ffff, 1, 50 * COIN);// Change time and set nonce =0

        if (startNewChain)
            MineGenesis(genesis, consensus.powLimit, false);
			
		//genesis = CreateGenesisBlock(1504695029, 8026361, 0x1f00ffff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        //assert(consensus.hashGenesisBlock == uint256S("0x000075aef83cf2853580f8ae8ce6f8c3096cfa21d98334d6e3f95e5582ed986c"));
        //assert(genesis.hashMerkleRoot == uint256S("0xed34050eb5909ee535fcb07af292ea55f3d2f291187617b44d3282231405b96d"));
		
		LogPrintf("Main Genesis nTime = %u n", genesis.nTime);
        LogPrintf("Main Genesis nNonce = %u n", genesis.nNonce);
        LogPrintf("Main Genesis nBits: %08xn", genesis.nBits);
        LogPrintf("Main Genesis Hash = %sn", genesis.GetHash().ToString().c_str());
        LogPrintf("Main Genesis hashStateRoot = %sn", genesis.hashStateRoot.ToString().c_str());
        LogPrintf("Main Genesis Hash Merkle Root = %sn", genesis.hashMerkleRoot.ToString().c_str());			
//End Debug Mainnet
	
####################### 2. Testnet #######################

Find and replace
#######################
        genesis = CreateGenesisBlock(1504695029, 7349697, 0x1f00ffff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x0000e803ee215c0684ca0d2f9220594d3f828617972aad66feb2ba51f5e14222"));
        assert(genesis.hashMerkleRoot == uint256S("0xed34050eb5909ee535fcb07af292ea55f3d2f291187617b44d3282231405b96d"));
#######################
with
#######################
//Debug Testnet
        startNewChain = true;
		
        genesis = CreateGenesisBlock(1645276728, 0, 0x1f00ffff, 1, 50 * COIN);// Change time and set nonce =0

        if (startNewChain)
            MineGenesis(genesis, consensus.powLimit, false);
			
        //genesis = CreateGenesisBlock(1504695029, 7349697, 0x1f00ffff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        //assert(consensus.hashGenesisBlock == uint256S("0x0000e803ee215c0684ca0d2f9220594d3f828617972aad66feb2ba51f5e14222"));
        //assert(genesis.hashMerkleRoot == uint256S("0xed34050eb5909ee535fcb07af292ea55f3d2f291187617b44d3282231405b96d"));

        LogPrintf("Test Genesis nTime = %u n", genesis.nTime);
        LogPrintf("Test Genesis nNonce = %u n", genesis.nNonce);
        LogPrintf("Test Genesis nBits: %08xn", genesis.nBits);
        LogPrintf("Test Genesis Hash = %sn", genesis.GetHash().ToString().c_str());
        LogPrintf("Test Genesis hashStateRoot = %sn", genesis.hashStateRoot.ToString().c_str());
        LogPrintf("Test Genesis Hash Merkle Root = %sn", genesis.hashMerkleRoot.ToString().c_str());
//End Debug Testnet		

####################### 3. Regtest #######################	

Find and replace
#######################
        genesis = CreateGenesisBlock(1504695029, 17, 0x207fffff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        assert(consensus.hashGenesisBlock == uint256S("0x665ed5b402ac0b44efc37d8926332994363e8a7278b7ee9a58fb972efadae943"));
        assert(genesis.hashMerkleRoot == uint256S("0xed34050eb5909ee535fcb07af292ea55f3d2f291187617b44d3282231405b96d"));
#######################
with
#######################
//Debug Regtest
        startNewChain = true;
		
        genesis = CreateGenesisBlock(1506211200, 17, 0x207fffff, 1, 50 * COIN);// Change time and set nonce = any number

        if (startNewChain)
            MineGenesis(genesis, consensus.powLimit, false);
			
        //genesis = CreateGenesisBlock(1504695029, 17, 0x207fffff, 1, 50 * COIN);
        consensus.hashGenesisBlock = genesis.GetHash();
        //assert(consensus.hashGenesisBlock == uint256S("0x665ed5b402ac0b44efc37d8926332994363e8a7278b7ee9a58fb972efadae943"));
        //assert(genesis.hashMerkleRoot == uint256S("0xed34050eb5909ee535fcb07af292ea55f3d2f291187617b44d3282231405b96d"));	

        LogPrintf("Reg Genesis nTime = %u n", genesis.nTime);
        LogPrintf("Reg Genesis nNonce = %u n", genesis.nNonce);
        LogPrintf("Reg Genesis nBits: %08xn", genesis.nBits);
        LogPrintf("Reg Genesis Hash = %sn", genesis.GetHash().ToString().c_str());
        LogPrintf("Reg Genesis hashStateRoot = %sn", genesis.hashStateRoot.ToString().c_str());
        LogPrintf("Reg Genesis Hash Merkle Root = %sn", genesis.hashMerkleRoot.ToString().c_str());		
//End Debug Regtest

		
			
##############################################
File src/chainparams.h

Add below

bool startNewChain;

before

CCheckpointData checkpointData;




############################### Build your debug chain #################################

sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils git cmake libboost-all-dev libgmp3-dev

sudo apt-get install software-properties-common

sudo add-apt-repository ppa:bitcoin/bitcoin

sudo apt-get update

sudo apt-get install libdb4.8-dev libdb4.8++-dev


sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler qrencode


./autogen.sh

./configure

make -j4

#### Take 20-30 min to complete ####


cd src/qt

./qtum-qt

qtum-qt: validation.cpp:1639: void InvalidChainFound(CBlockIndex*): Assertion `tip' failed.
Aborted (core dumped)

############################## Find genesis hash, nonce debug.log ##################################

Ctr H

View hidden file and folder


############## MainNet Find ##############

2022-02-19T14:16:06Z Main Genesis nTime = 1645278122 
2022-02-19T14:16:06Z Main Genesis nNonce = 35110 
2022-02-19T14:16:06Z Main Genesis nBits: 1f00ffff
2022-02-19T14:16:06Z Main Genesis Hash = 00007c13b508f80a556139c390a06ee51e59ecd9246e03bf00acac4299a508b0
2022-02-19T14:16:06Z Main Genesis hashStateRoot = 9514771014c9ae803d8cea2731b2063e83de44802b40dce2d06acd02d0ff65e9
2022-02-19T14:16:06Z Main Genesis Hash Merkle Root = 49e2dd855ad104b945cd2f6980d7d69d0470bc69646dbdb77a275b4196f7a55f

############## TestNet Find ##############

2022-02-19T14:16:06Z Test Genesis nTime = 1645278327 
2022-02-19T14:16:06Z Test Genesis nNonce = 13721 
2022-02-19T14:16:06Z Test Genesis nBits: 1f00ffff
2022-02-19T14:16:06Z Test Genesis Hash = 00008067af1d36cacf194d0f0508ee0f58371314b84e21cbf4ec3d60f1f4cc2c
2022-02-19T14:16:06Z Test Genesis hashStateRoot = 9514771014c9ae803d8cea2731b2063e83de44802b40dce2d06acd02d0ff65e9
2022-02-19T14:16:06Z Test Genesis Hash Merkle Root = 49e2dd855ad104b945cd2f6980d7d69d0470bc69646dbdb77a275b4196f7a55f

############## RegTest Find ##############

2022-02-19T14:16:06Z Reg Genesis nTime = 1645278420 
2022-02-19T14:16:06Z Reg Genesis nNonce = 1 
2022-02-19T14:16:06Z Reg Genesis nBits: 207fffff
2022-02-19T14:16:06Z Reg Genesis Hash = 71b2f068167ce06588cb167d10acbffc4e069ab6172fc5db6c24e3e83e10e1b9
2022-02-19T14:16:06Z Reg Genesis hashStateRoot = 9514771014c9ae803d8cea2731b2063e83de44802b40dce2d06acd02d0ff65e9
2022-02-19T14:16:06Z Reg Genesis Hash Merkle Root = 49e2dd855ad104b945cd2f6980d7d69d0470bc69646dbdb77a275b4196f7a55f

############################## Change back your chainparams.cpp with new info ##################################

Remove //Debug Mainnet
Remove //Debug Testnet
Remove //Debug Regtest


############################## Change back your chainparams.h ##################################

src/chainparams.h 

Remove

bool startNewChain;


############################### Build your new chain #################################

cd ../..

make -j4

cd src/qt

./qtum-qt


Now you completed fork Qtum for new chain

Let check

Have Fun
Good luck!

Nguồn: viblo.asia

Bài viết liên quan

WebP là gì? Hướng dẫn cách để chuyển hình ảnh jpg, png qua webp

WebP là gì? WebP là một định dạng ảnh hiện đại, được phát triển bởi Google

Điểm khác biệt giữa IPv4 và IPv6 là gì?

IPv4 và IPv6 là hai phiên bản của hệ thống địa chỉ Giao thức Internet (IP). IP l

Check nameservers của tên miền xem website trỏ đúng chưa

Tìm hiểu cách check nameservers của tên miền để xác định tên miền đó đang dùn

Mình đang dùng Google Domains để check tên miền hàng ngày

Từ khi thông báo dịch vụ Google Domains bỏ mác Beta, mình mới để ý và bắt đầ