- // Copyright (c) 2010 Satoshi Nakamoto
- // Copyright (c) 2009-2016 The Starwels developers
- // Distributed under the MIT software license, see the accompanying
- // file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
- #include "chainparams.h"
- #include "consensus/merkle.h"
-
- #include "tinyformat.h"
- #include "util.h"
- #include "utilstrencodings.h"
-
- #include <assert.h>
-
- #include "chainparamsseeds.h"
-
- static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
- {
- CMutableTransaction txNew;
- txNew.nVersion = 1;
- txNew.vin.resize(1);
- txNew.vout.resize(1);
- txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
- txNew.vout[0].nValue = genesisReward;
- txNew.vout[0].scriptPubKey = genesisOutputScript;
-
- CBlock genesis;
- genesis.nTime = nTime;
- genesis.nBits = nBits;
- genesis.nNonce = nNonce;
- genesis.nVersion = nVersion;
- genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
- genesis.hashPrevBlock.SetNull();
- genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
- return genesis;
- }
-
- static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
- {
- const char* pszTimestamp = "January/20/2017 45th President of the United States of America Donald Trump";
- const CScript genesisOutputScript = CScript() << ParseHex("04ea1e6e7cace7b63b88949a3f43f0144b0032eaa9ee6c9627fc58bfb51163a262542fd8cdd3cc40186a1aeeb4857c15954e6f15f789bfdcf9cec59863cdfc6e14") << OP_CHECKSIG;
- return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
- }
-
- void CChainParams::UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
- {
- consensus.vDeployments[d].nStartTime = nStartTime;
- consensus.vDeployments[d].nTimeout = nTimeout;
- }
-
- /**
- * Main Network
- */
-
- /**
- * What makes a good checkpoint block?
- * + Is surrounded by blocks with reasonable timestamps
- * (no blocks before with a timestamp after, none after with
- * timestamp before)
- * + Contains no strange transactions
- */
- class CMainParams : public CChainParams {
- public:
- CMainParams() {
- strNetworkID = "main";
- consensus.nSubsidyHalvingInterval = 210000;
- consensus.BIP34Height = 227931;
- consensus.BIP34Hash = uint256S("0x00000000ac6a39893714f4240301f40abff1afcdcaf51d2f40ce6675a73f0961");
- consensus.BIP65Height = 388381;
- consensus.BIP66Height = 363725;
- consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- consensus.nPowTargetTimespan = 2 * 24 * 84;
- consensus.nPowTargetSpacing = 2; // 2 second
- consensus.fPowAllowMinDifficultyBlocks = false;
- consensus.fPowNoRetargeting = false;
- consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
- consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1498867200; // July 1 Saturday, 2017
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1530403200; // July 1 Sunday, 2018
-
- // Deployment of BIP68, BIP112, and BIP113.
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1501545600; // August 1 Tuesday, 2017
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1533081600; // August 1 Wednesday, 2018
-
- // Deployment of SegWit (BIP141, BIP143, and BIP147)
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1504224000; // September 1 Friday, 2017
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1535760000; // September 1 Saturday, 2018
-
- // The best chain should have at least this much work.
- consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000006550f67b8b239");
-
- // By default assume that the signatures in ancestors of this block are valid.
- consensus.defaultAssumeValid = uint256S("0x00000000764077b29d13e1cb2484f028a24ef2a44486b6e5d3cb17eb4716c465"); // 262144
-
- /**
- * The message start string is designed to be unlikely to occur in normal data.
- * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
- * a large 32-bit integer with any alignment.
- */
- pchMessageStart[0] = 0xf9;
- pchMessageStart[1] = 0xbe;
- pchMessageStart[2] = 0xb4;
- pchMessageStart[3] = 0xd9;
- nDefaultPort = 8343;
- nPruneAfterHeight = 100000;
-
- genesis = CreateGenesisBlock(1484870400, 2121032621, 0x1d00ffff, 1, 50 * COIN);
- consensus.hashGenesisBlock = genesis.GetHash();
- assert(consensus.hashGenesisBlock == uint256S("0x000000003d69a915e9da53348c5c272978bb743442e3a6341c11061c125811a2"));
- assert(genesis.hashMerkleRoot == uint256S("0x7e2c59b1404833991962e7e6d95a1d4f81f03fffeaf79c0d25d97d24182db485"));
-
- // Note that of those with the service bits flag, most only support a subset of possible options
-
- base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
- base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
- base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,128);
- base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
- base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
-
- vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
-
- fDefaultConsistencyChecks = false;
- fRequireStandard = true;
- fMineBlocksOnDemand = false;
-
- checkpointData = (CCheckpointData) {
- {
- {1024, uint256S("0x00000000fb559851169e0d915093533d31af0d963e06a7d80a20496f9cfd2b9f")},
- {2048, uint256S("0x00000000a753b360bb5d54908378d999132fbeb415279ef530b397ae249cbef4")},
- {4096, uint256S("0x00000000d7674ad1e7703e7ba02b7611c12fe74de27b6a414cf6e906cc3599e9")},
- {8192, uint256S("0x000000007039ae6930925c9c6297835642ea5a4d6f32cef2f6b84867e049fff8")},
- {32768, uint256S("0x00000000cc19cff47d676ad56594e695ac96a1d2781a83a5fd1a7702b98a9a65")},
- {65536, uint256S("0x00000000c6814c6715cda6f76b08b967abc0ea70aa3f8db8e8c62206477cb749")},
- {131072, uint256S("0x00000000dbff9cae44489b3c02bbd556b67db5e3d21318c35cca0b6c361e6944")},
- }
- };
-
- chainTxData = ChainTxData{
- // Data as of block 00000000764077b29d13e1cb2484f028a24ef2a44486b6e5d3cb17eb4716c465 (height 262144).
- 1530692464, // * UNIX timestamp of last known number of transactions
- 262230, // * total number of transactions between genesis and that timestamp
- // (the tx=... number in the SetBestChain debug.log lines)
- 3.1 // * estimated number of transactions per second after that timestamp
- };
- }
- };
-
- /**
- * Starwels Ai Main Network
- */
- class CTestNetParams : public CChainParams {
- public:
- CTestNetParams() {
- strNetworkID = "main";
- consensus.nSubsidyHalvingInterval = 210000;
- consensus.BIP34Height = 227931;
- consensus.BIP34Hash = uint256S("0x00000000ac6a39893714f4240301f40abff1afcdcaf51d2f40ce6675a73f0961");
- consensus.BIP65Height = 388381;
- consensus.BIP66Height = 363725;
- consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- consensus.nPowTargetTimespan = 2 * 24 * 84;
- consensus.nPowTargetSpacing = 2; // 2 second
- consensus.fPowAllowMinDifficultyBlocks = false;
- consensus.fPowNoRetargeting = false;
- consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
- consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1498867200; // July 1 Saturday, 2017
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1530403200; // July 1 Sunday, 2018
-
- // Deployment of BIP68, BIP112, and BIP113.
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1501545600; // August 1 Tuesday, 2017
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1533081600; // August 1 Wednesday, 2018
-
- // Deployment of SegWit (BIP141, BIP143, and BIP147)
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1504224000; // September 1 Friday, 2017
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1535760000; // September 1 Saturday, 2018
-
- // The best chain should have at least this much work.
- consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000100110011001");
-
- // By default assume that the signatures in ancestors of this block are valid.
- consensus.defaultAssumeValid = uint256S("0x00000000d7674ad1e7703e7ba02b7611c12fe74de27b6a414cf6e906cc3599e9"); // 4096
-
- pchMessageStart[0] = 0xf9;
- pchMessageStart[1] = 0xbe;
- pchMessageStart[2] = 0xb4;
- pchMessageStart[3] = 0xd9;
- nDefaultPort = 8333;
- nPruneAfterHeight = 100000;
-
- genesis = CreateGenesisBlock(1484870400, 2121032621, 0x1d00ffff, 1, 50 * COIN);
- consensus.hashGenesisBlock = genesis.GetHash();
- assert(consensus.hashGenesisBlock == uint256S("0x000000003d69a915e9da53348c5c272978bb743442e3a6341c11061c125811a2"));
- assert(genesis.hashMerkleRoot == uint256S("0x7e2c59b1404833991962e7e6d95a1d4f81f03fffeaf79c0d25d97d24182db485"));
-
- vFixedSeeds.clear();
- vSeeds.clear();
- // nodes with support for servicebits filtering should be at the top
-
- base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
- base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
- base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,128);
- base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
- base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
-
- vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
-
- fDefaultConsistencyChecks = false;
- fRequireStandard = true;
- fMineBlocksOnDemand = false;
-
- checkpointData = (CCheckpointData) {
- {
- {1024, uint256S("0x00000000fb559851169e0d915093533d31af0d963e06a7d80a20496f9cfd2b9f")},
- {2048, uint256S("0x00000000a753b360bb5d54908378d999132fbeb415279ef530b397ae249cbef4")},
- }
- };
-
- chainTxData = ChainTxData{
- // Data as of block 00000000d7674ad1e7703e7ba02b7611c12fe74de27b6a414cf6e906cc3599e9 (height 4096).
- 1529914513, // * UNIX timestamp of last known number of transactions
- 4172, // * total number of transactions between genesis and that timestamp
- // (the tx=... number in the SetBestChain debug.log lines)
- 3.1 // * estimated number of transactions per second after that timestamp
- };
-
- }
- };
-
- /**
- * Regression test
- */
- class CRegTestParams : public CChainParams {
- public:
- CRegTestParams() {
- strNetworkID = "regtest";
- consensus.nSubsidyHalvingInterval = 150;
- consensus.BIP34Height = 100000000; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests)
- consensus.BIP34Hash = uint256();
- consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
- consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
- consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- consensus.nPowTargetTimespan = 2 * 24 * 84;
- consensus.nPowTargetSpacing = 2; // 2 second
- consensus.fPowAllowMinDifficultyBlocks = true;
- consensus.fPowNoRetargeting = true;
- consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
- consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
- consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 999999999999ULL;
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
- consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 999999999999ULL;
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 0;
- consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 999999999999ULL;
-
- // The best chain should have at least this much work.
- consensus.nMinimumChainWork = uint256S("0x00");
-
- // By default assume that the signatures in ancestors of this block are valid.
- consensus.defaultAssumeValid = uint256S("0x00");
-
- pchMessageStart[0] = 0xfa;
- pchMessageStart[1] = 0xbf;
- pchMessageStart[2] = 0xb5;
- pchMessageStart[3] = 0xda;
- nDefaultPort = 18444;
- nPruneAfterHeight = 1000;
-
- genesis = CreateGenesisBlock(1484956800, 0, 0x207fffff, 1, 50 * COIN);
- consensus.hashGenesisBlock = genesis.GetHash();
- assert(consensus.hashGenesisBlock == uint256S("0x79a6a4d5e19d4e5c6783691ba9ad75c7c352f906275b93dcad27ea0c3017ec80"));
- assert(genesis.hashMerkleRoot == uint256S("0x7e2c59b1404833991962e7e6d95a1d4f81f03fffeaf79c0d25d97d24182db485"));
-
- vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
- vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
-
- fDefaultConsistencyChecks = true;
- fRequireStandard = false;
- fMineBlocksOnDemand = true;
-
- checkpointData = (CCheckpointData) {
- {
- {0, uint256S("79a6a4d5e19d4e5c6783691ba9ad75c7c352f906275b93dcad27ea0c3017ec80")},
- }
- };
-
- chainTxData = ChainTxData{
- 0,
- 0,
- 0
- };
-
- base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
- base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
- base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
- base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
- base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
- }
- };
-
- static std::unique_ptr<CChainParams> globalChainParams;
-
- const CChainParams &Params() {
- assert(globalChainParams);
- return *globalChainParams;
- }
-
- std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain)
- {
- if (chain == CBaseChainParams::MAIN)
- return std::unique_ptr<CChainParams>(new CMainParams());
- else if (chain == CBaseChainParams::AI)
- return std::unique_ptr<CChainParams>(new CTestNetParams());
- else if (chain == CBaseChainParams::REGTEST)
- return std::unique_ptr<CChainParams>(new CRegTestParams());
- throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
- }
-
- void SelectParams(const std::string& network)
- {
- SelectBaseParams(network);
- globalChainParams = CreateChainParams(network);
- }
-
- void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
- {
- globalChainParams->UpdateVersionBitsParameters(d, nStartTime, nTimeout);
- }
|