From 479efb0e70158124e0da247203a4d6e3b80c1da9 Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Tue, 4 Sep 2018 22:32:27 -0700 Subject: [PATCH] WIP: started working on genesis block. --- src/chainparams.cpp | 61 +++++++++++++++++++++++++++++++++++++++------ src/util.cpp | 6 ++--- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 5e38647d6..01669e8dc 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -3,6 +3,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include #include #include @@ -50,7 +51,7 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) { const char* pszTimestamp = "NY Times 05/Oct/2011 Steve Jobs, Appleā€™s Visionary, Dies at 56"; - const CScript genesisOutputScript = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG; + const CScript genesisOutputScript = CScript() << ParseHex("049451c9ac3be691a4fa375ea69537a46ef374c1f454dbc7c2c6fe27b280f2b979991aadb29358591a1f72c326b537d7fd03e14d4978a1b57486d9e6d2c3645717") << OP_CHECKSIG; return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward); } @@ -81,7 +82,7 @@ public: consensus.BIP34Hash = uint256S("fa09d204a83a768ed5a7c8d441fa62f2043abf420cff1226c7b4329aeb9d51cf"); consensus.BIP65Height = 918684; // bab3041e8977e0dc3eeff63fe707b92bde1dd449d8efafb248c27c8264cc311a consensus.BIP66Height = 811879; // 7aceee012833fa8952f8835d8b1b3ae233cd6ab08fdb27a771d2bd7bdc491894 - consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 3.5 * 24 * 60 * 60; // 3.5 days consensus.nPowTargetSpacing = 2.5 * 60; consensus.fPowAllowMinDifficultyBlocks = false; @@ -121,6 +122,21 @@ public: nPruneAfterHeight = 100000; genesis = CreateGenesisBlock(1317972665, 2084524493, 0x1e0ffff0, 1, 50 * COIN); + + //JW remove the following code! + arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits); + uint256 hashGenesisBlock = uint256S("0x01"); + if (true && genesis.GetHash() != hashGenesisBlock) { + printf("recalculating params for mainnet.\n"); + printf("old mainnet genesis nonce: %d\n", genesis.nNonce); + printf("old mainnet genesis hash: %s\n", hashGenesisBlock.ToString().c_str()); + // deliberately empty for loop finds nonce value. + for(genesis.nNonce = 0; hashTarget < UintToArith256(genesis.GetHash()); genesis.nNonce++){} + printf("new mainnet genesis merkle root: %s\n", genesis.hashMerkleRoot.ToString().c_str()); + printf("new mainnet genesis nonce: %d\n", genesis.nNonce); + printf("new mainnet genesis hash: %s\n", genesis.GetHash().ToString().c_str()); + } + consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2")); assert(genesis.hashMerkleRoot == uint256S("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9")); @@ -131,6 +147,7 @@ public: vSeeds.emplace_back("dnsseed.litecointools.com"); vSeeds.emplace_back("dnsseed.litecoinpool.org"); vSeeds.emplace_back("dnsseed.koin-project.com"); + vSeeds.clear(); //JW remove this! base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,48); base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,5); @@ -142,6 +159,7 @@ public: bech32_hrp = "ltc"; vFixedSeeds = std::vector(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); + vFixedSeeds.clear(); //JW remove this! fDefaultConsistencyChecks = false; fRequireStandard = true; @@ -218,14 +236,28 @@ public: // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S("0x1efb29c8187d5a496a33377941d1df415169c3ce5d8c05d055f25b683ec3f9a3"); //612653 - pchMessageStart[0] = 0xfd; - pchMessageStart[1] = 0xd2; - pchMessageStart[2] = 0xc8; - pchMessageStart[3] = 0xf1; + pchMessageStart[0] = 0x6a; + pchMessageStart[1] = 0xc6; + pchMessageStart[2] = 0x07; + pchMessageStart[3] = 0x9a; nDefaultPort = 19335; nPruneAfterHeight = 1000; genesis = CreateGenesisBlock(1486949366, 293345, 0x1e0ffff0, 1, 50 * COIN); + //JW remove the following code! + arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits); + uint256 hashGenesisBlock = uint256S("0x01"); + if (true && genesis.GetHash() != hashGenesisBlock) { + printf("recalculating params for mainnet.\n"); + printf("old mainnet genesis nonce: %d\n", genesis.nNonce); + printf("old mainnet genesis hash: %s\n", hashGenesisBlock.ToString().c_str()); + // deliberately empty for loop finds nonce value. + for(genesis.nNonce = 0; hashTarget < UintToArith256(genesis.GetHash()); genesis.nNonce++){} + printf("new mainnet genesis merkle root: %s\n", genesis.hashMerkleRoot.ToString().c_str()); + printf("new mainnet genesis nonce: %d\n", genesis.nNonce); + printf("new mainnet genesis hash: %s\n", genesis.GetHash().ToString().c_str()); + } + consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x4966625a4b2851d9fdee139e56211a0d88575f59ed816ff5e6a63deb4e3e29a0")); assert(genesis.hashMerkleRoot == uint256S("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9")); @@ -236,6 +268,7 @@ public: vSeeds.emplace_back("testnet-seed.litecointools.com"); vSeeds.emplace_back("seed-b.litecoin.loshan.co.uk"); vSeeds.emplace_back("dnsseed-testnet.thrasher.io"); + vSeeds.clear(); // JWU remove this! base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,111); base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,196); @@ -312,6 +345,20 @@ public: nPruneAfterHeight = 1000; genesis = CreateGenesisBlock(1296688602, 0, 0x207fffff, 1, 50 * COIN); + //JW remove the following code! + arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits); + uint256 hashGenesisBlock = uint256S("0x01"); + if (true && genesis.GetHash() != hashGenesisBlock) { + printf("recalculating params for mainnet.\n"); + printf("old mainnet genesis nonce: %d\n", genesis.nNonce); + printf("old mainnet genesis hash: %s\n", hashGenesisBlock.ToString().c_str()); + // deliberately empty for loop finds nonce value. + for(genesis.nNonce = 0; hashTarget < UintToArith256(genesis.GetHash()); genesis.nNonce++){} + printf("new mainnet genesis merkle root: %s\n", genesis.hashMerkleRoot.ToString().c_str()); + printf("new mainnet genesis nonce: %d\n", genesis.nNonce); + printf("new mainnet genesis hash: %s\n", genesis.GetHash().ToString().c_str()); + } + consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9")); assert(genesis.hashMerkleRoot == uint256S("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9")); @@ -321,7 +368,7 @@ public: fDefaultConsistencyChecks = true; fRequireStandard = false; - fMineBlocksOnDemand = true; + fMineBlocksOnDemand = true; checkpointData = { { diff --git a/src/util.cpp b/src/util.cpp index a598b2463..5486f5a86 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -583,7 +583,7 @@ fs::path GetDefaultDataDir() // Unix: ~/.bitcoin #ifdef WIN32 // Windows - return GetSpecialFolderPath(CSIDL_APPDATA) / "Litecoin"; + return GetSpecialFolderPath(CSIDL_APPDATA) / "Kevacoin"; #else fs::path pathRet; char* pszHome = getenv("HOME"); @@ -593,10 +593,10 @@ fs::path GetDefaultDataDir() pathRet = fs::path(pszHome); #ifdef MAC_OSX // Mac - return pathRet / "Library/Application Support/Litecoin"; + return pathRet / "Library/Application Support/Kevacoin"; #else // Unix - return pathRet / ".litecoin"; + return pathRet / ".kevacoin"; #endif #endif }