[text] testcoinhelpforum

Viewer

copydownloadembedprintName: testcoinhelpforum
  1. // Copyright (c) 2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2020 The Bitcoin Core developers
  3. // Distributed under the MIT software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5.  
  6. #include <chainparams.h>
  7.  
  8. #include <chainparamsseeds.h>
  9. #include <consensus/merkle.h>
  10. #include <hash.h> // for signet block challenge hash
  11. #include <util/system.h>
  12. #include <versionbitsinfo.h>
  13.  
  14. #include <assert.h>
  15.  
  16. #include <boost/algorithm/string/classification.hpp>
  17. #include <boost/algorithm/string/split.hpp>
  18.  
  19. static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
  20. {
  21.     CMutableTransaction txNew;
  22.     txNew.nVersion = 1;
  23.     txNew.vin.resize(1);
  24.     txNew.vout.resize(1);
  25.     txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
  26.     txNew.vout[0].nValue = genesisReward;
  27.     txNew.vout[0].scriptPubKey = genesisOutputScript;
  28.  
  29.     CBlock genesis;
  30.     genesis.nTime    = nTime;
  31.     genesis.nBits    = nBits;
  32.     genesis.nNonce   = nNonce;
  33.     genesis.nVersion = nVersion;
  34.     genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
  35.     genesis.hashPrevBlock.SetNull();
  36.     genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
  37.     return genesis;
  38. }
  39.  
  40. /**
  41.  * Build the genesis block. Note that the output of its generation
  42.  * transaction cannot be spent since it did not originally exist in the
  43.  * database.
  44.  *
  45.  * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
  46.  *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
  47.  *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
  48.  *     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
  49.  *   vMerkleTree: 4a5e1e
  50.  */
  51. static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
  52. {
  53.     const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
  54.     const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
  55.     return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
  56. }
  57.  
  58. /**
  59.  * Main network
  60.  */
  61. class CMainParams : public CChainParams {
  62. public:
  63.     CMainParams() {
  64.         strNetworkID = CBaseChainParams::MAIN;
  65.         consensus.signet_blocks = false;
  66.         consensus.signet_challenge.clear();
  67.         consensus.nSubsidyHalvingInterval = 210000;
  68.         consensus.BIP16Exception = uint256();
  69.         consensus.BIP34Height = 0;
  70.         consensus.BIP34Hash = uint256S();
  71.         consensus.BIP65Height = 0;
  72.         consensus.BIP66Height = 0;
  73.         consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
  74.         consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
  75.         consensus.MinBIP9WarningHeight = 483840; // segwit activation height + miner confirmation window
  76.         consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
  77.         consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
  78.         consensus.nPowTargetSpacing = 10 * 60;
  79.         consensus.fPowAllowMinDifficultyBlocks = false;
  80.         consensus.fPowNoRetargeting = false;
  81.         consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
  82.         consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
  83.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
  84.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
  85.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
  86.  
  87.         // Deployment of Taproot (BIPs 340-342)
  88.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
  89.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1199145601; // January 1, 2008
  90.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1230767999; // December 31, 2008
  91.  
  92.         // Deployment of BIP68, BIP112, and BIP113.
  93.         consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
  94.         consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
  95.         consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
  96.  
  97.          // Deployment of SegWit (BIP141, BIP143, and BIP147)
  98.         consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
  99.         consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
  100.         consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
  101.  
  102.  
  103.         consensus.nMinimumChainWork = consensus.powLimit;
  104.         consensus.defaultAssumeValid = uint256();
  105.  
  106.         /**
  107.          * The message start string is designed to be unlikely to occur in normal data.
  108.          * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
  109.          * a large 32-bit integer with any alignment.
  110.          */
  111.  
  112.         pchMessageStart[0] = 0xbb;
  113.         pchMessageStart[1] = 0xd7;
  114.         pchMessageStart[2] = 0xcd;
  115.         pchMessageStart[3] = 0xae;
  116.         nDefaultPort = 8433;
  117.         nPruneAfterHeight = 100000;
  118.         m_assumed_blockchain_size = 350;
  119.         m_assumed_chain_state_size = 6;
  120.  
  121.         genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
  122.         consensus.hashGenesisBlock = genesis.GetHash();
  123.         assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
  124.         assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
  125.  
  126.         // Note that of those which support the service bits prefix, most only support a subset of
  127.         // possible options.
  128.         // This is fine at runtime as we'll fall back to using them as an addrfetch if they don't support the
  129.         // service bits we want, but we should get them updated to support all service bits wanted by any
  130.         // release ASAP to avoid it where possible.
  131.         vSeeds.emplace_back("seed.testcoin.sipa.be"); // Pieter Wuille, only supports x1, x5, x9, and xd
  132.         vSeeds.emplace_back("dnsseed.bluematt.me"); // Matt Corallo, only supports x9
  133.         vSeeds.emplace_back("dnsseed.testcoin.dashjr.org"); // Luke Dashjr
  134.         vSeeds.emplace_back("seed.testcoinstats.com"); // Christian Decker, supports x1 - xf
  135.         vSeeds.emplace_back("seed.testcoin.jonasschnelli.ch"); // Jonas Schnelli, only supports x1, x5, x9, and xd
  136.         vSeeds.emplace_back("seed.btc.petertodd.org"); // Peter Todd, only supports x1, x5, x9, and xd
  137.         vSeeds.emplace_back("seed.testcoin.sprovoost.nl"); // Sjors Provoost
  138.         vSeeds.emplace_back("dnsseed.emzy.de"); // Stephan Oeste
  139.         vSeeds.emplace_back("seed.testcoin.wiz.biz"); // Jason Maurice
  140.  
  141.         base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,45);
  142.         base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,48);
  143.         base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,128);
  144.         base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
  145.         base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
  146.  
  147.         bech32_hrp = "ac";
  148.  
  149.         vFixedSeeds = std::vector<SeedSpec6>(std::begin(pnSeed6_main), std::end(pnSeed6_main));
  150.  
  151.         fDefaultConsistencyChecks = false;
  152.         fRequireStandard = true;
  153.         m_is_test_chain = false;
  154.         m_is_mockable_chain = false;
  155.  
  156.         checkpointData = {
  157.             {
  158.             }
  159.         };
  160.  
  161.         m_assumeutxo_data = MapAssumeutxo{
  162.          // TODO to be specified in a future patch.
  163.         };
  164.  
  165.         chainTxData = ChainTxData{
  166.     // Data from rpc: getchaintxstats 4096 0000000000000000002e63058c023a9a1de233554f28c7b21380b6c9003f36a8
  167.     /* nTime    */ 0,//1532884444,
  168.     /* nTxCount */ 0,//331282217,
  169.     /* dTxRate  */ 0,//2.4
  170.         };
  171.     }
  172. };
  173.  
  174. /**
  175.  * Testnet (v3)
  176.  */
  177. class CTestNetParams : public CChainParams {
  178. public:
  179.     CTestNetParams() {
  180.         strNetworkID = CBaseChainParams::TESTNET;
  181.         consensus.signet_blocks = false;
  182.         consensus.signet_challenge.clear();
  183.         consensus.nSubsidyHalvingInterval = 210000;
  184.         consensus.BIP16Exception = uint256();
  185.         consensus.BIP34Height = ;
  186.         consensus.BIP34Hash = uint256S();
  187.         consensus.BIP65Height = 0;
  188.         consensus.BIP66Height = 0;
  189.         consensus.CSVHeight = 770112; // 00000000025e930139bac5c6c31a403776da130831ab85be56578f3fa75369bb
  190.         consensus.SegwitHeight = 834624; // 00000000002b980fcd729daaa248fd9316a5200e9b367f4ff2c42453e84201ca
  191.         consensus.MinBIP9WarningHeight = 836640; // segwit activation height + miner confirmation window
  192.         consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
  193.         consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
  194.         consensus.nPowTargetSpacing = 10 * 60;
  195.         consensus.fPowAllowMinDifficultyBlocks = true;
  196.         consensus.fPowNoRetargeting = false;
  197.         consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
  198.         consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
  199.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
  200.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
  201.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
  202.  
  203.         // Deployment of Taproot (BIPs 340-342)
  204.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
  205.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1199145601; // January 1, 2008
  206.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1230767999; // December 31, 2008
  207.  
  208.         // Deployment of BIP68, BIP112, and BIP113.
  209.         consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
  210.         consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
  211.         consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
  212.  
  213.          // Deployment of SegWit (BIP141, BIP143, and BIP147)
  214.         consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
  215.         consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
  216.         consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
  217.  
  218.  
  219.         consensus.nMinimumChainWork = consensus.powLimit;
  220.         consensus.defaultAssumeValid = uint256S();
  221.  
  222.         pchMessageStart[0] = 0xc0;
  223.         pchMessageStart[1] = 0xeb;
  224.         pchMessageStart[2] = 0xce;
  225.         pchMessageStart[3] = 0xad;
  226.         nDefaultPort = 18433;
  227.         nPruneAfterHeight = 1000;
  228.         m_assumed_blockchain_size = 40;
  229.         m_assumed_chain_state_size = 2;
  230.  
  231.         genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
  232.         consensus.hashGenesisBlock = genesis.GetHash();
  233.         assert(consensus.hashGenesisBlock == uint256S("0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"));
  234.         assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
  235.  
  236.         vFixedSeeds.clear();
  237.         vSeeds.clear();
  238.         // nodes with support for servicebits filtering should be at the top
  239.         vSeeds.emplace_back("testnet-seed.testcoin.jonasschnelli.ch");
  240.         vSeeds.emplace_back("seed.tbtc.petertodd.org");
  241.         vSeeds.emplace_back("seed.testnet.testcoin.sprovoost.nl");
  242.         vSeeds.emplace_back("testnet-seed.bluematt.me"); // Just a static list of stable node(s), only supports x9
  243.  
  244.         base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,107);
  245.         base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,65);
  246.         base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
  247.         base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
  248.         base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
  249.  
  250.         bech32_hrp = "tb";
  251.  
  252.         vFixedSeeds = std::vector<SeedSpec6>(std::begin(pnSeed6_test), std::end(pnSeed6_test));
  253.  
  254.         fDefaultConsistencyChecks = false;
  255.         fRequireStandard = false;
  256.         m_is_test_chain = true;
  257.         m_is_mockable_chain = false;
  258.  
  259.         checkpointData = {
  260.             {
  261.             }
  262.         };
  263.  
  264.         m_assumeutxo_data = MapAssumeutxo{
  265.             // TODO to be specified in a future patch.
  266.         };
  267.  
  268.         chainTxData = ChainTxData{
  269.             // Data from RPC: getchaintxstats 4096 0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75
  270.             /* nTime    */ 0,//1531929919,
  271.             /* nTxCount */ 0,//19438708,
  272.             /* dTxRate  */ 0,//0.626
  273.         };
  274.     }
  275. };
  276.  
  277. /**
  278.  * Signet
  279.  */
  280. class SigNetParams : public CChainParams {
  281. public:
  282.     explicit SigNetParams(const ArgsManager& args) {
  283.         std::vector<uint8_t> bin;
  284.         vSeeds.clear();
  285.  
  286.         if (!args.IsArgSet("-signetchallenge")) {
  287.             bin = ParseHex("512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae");
  288.             vSeeds.emplace_back("178.128.221.177");
  289.             vSeeds.emplace_back("2a01:7c8:d005:390::5");
  290.             vSeeds.emplace_back("v7ajjeirttkbnt32wpy3c6w3emwnfr3fkla7hpxcfokr3ysd3kqtzmqd.onion:38333");
  291.  
  292.             consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000000000019fd16269a");
  293.             consensus.defaultAssumeValid = uint256S("0x0000002a1de0f46379358c1fd09906f7ac59adf3712323ed90eb59e4c183c020"); // 9434
  294.             m_assumed_blockchain_size = 1;
  295.             m_assumed_chain_state_size = 0;
  296.             chainTxData = ChainTxData{
  297.                 // Data from RPC: getchaintxstats 4096 0000002a1de0f46379358c1fd09906f7ac59adf3712323ed90eb59e4c183c020
  298.                 /* nTime    */ 1603986000,
  299.                 /* nTxCount */ 9582,
  300.                 /* dTxRate  */ 0.00159272030651341,
  301.             };
  302.         } else {
  303.             const auto signet_challenge = args.GetArgs("-signetchallenge");
  304.             if (signet_challenge.size() != 1) {
  305.                 throw std::runtime_error(strprintf("%s: -signetchallenge cannot be multiple values.", __func__));
  306.             }
  307.             bin = ParseHex(signet_challenge[0]);
  308.  
  309.             consensus.nMinimumChainWork = uint256{};
  310.             consensus.defaultAssumeValid = uint256{};
  311.             m_assumed_blockchain_size = 0;
  312.             m_assumed_chain_state_size = 0;
  313.             chainTxData = ChainTxData{
  314.                 0,
  315.                 0,
  316.                 0,
  317.             };
  318.             LogPrintf("Signet with challenge %s\n", signet_challenge[0]);
  319.         }
  320.  
  321.         if (args.IsArgSet("-signetseednode")) {
  322.             vSeeds = args.GetArgs("-signetseednode");
  323.         }
  324.  
  325.         strNetworkID = CBaseChainParams::SIGNET;
  326.         consensus.signet_blocks = true;
  327.         consensus.signet_challenge.assign(bin.begin(), bin.end());
  328.         consensus.nSubsidyHalvingInterval = 210000;
  329.         consensus.BIP16Exception = uint256{};
  330.         consensus.BIP34Height = 1;
  331.         consensus.BIP34Hash = uint256{};
  332.         consensus.BIP65Height = 1;
  333.         consensus.BIP66Height = 1;
  334.         consensus.CSVHeight = 1;
  335.         consensus.SegwitHeight = 1;
  336.         consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
  337.         consensus.nPowTargetSpacing = 10 * 60;
  338.         consensus.fPowAllowMinDifficultyBlocks = false;
  339.         consensus.fPowNoRetargeting = false;
  340.         consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
  341.         consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
  342.         consensus.MinBIP9WarningHeight = 0;
  343.         consensus.powLimit = uint256S("00000377ae000000000000000000000000000000000000000000000000000000");
  344.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
  345.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
  346.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
  347.  
  348.         // Activation of Taproot (BIPs 340-342)
  349.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
  350.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
  351.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
  352.  
  353.         // message start is defined as the first 4 bytes of the sha256d of the block script
  354.         CHashWriter h(SER_DISK, 0);
  355.         h << consensus.signet_challenge;
  356.         uint256 hash = h.GetHash();
  357.         memcpy(pchMessageStart, hash.begin(), 4);
  358.  
  359.         nDefaultPort = 38333;
  360.         nPruneAfterHeight = 1000;
  361.  
  362.         genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 50 * COIN);
  363.         consensus.hashGenesisBlock = genesis.GetHash();
  364.         assert(consensus.hashGenesisBlock == uint256S("0x00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"));
  365.         assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
  366.  
  367.         vFixedSeeds.clear();
  368.  
  369.         base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,107);
  370.         base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,65);
  371.         base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
  372.         base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
  373.         base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
  374.  
  375.         bech32_hrp = "ta";
  376.  
  377.         fDefaultConsistencyChecks = false;
  378.         fRequireStandard = true;
  379.         m_is_test_chain = true;
  380.         m_is_mockable_chain = false;
  381.     }
  382. };
  383.  
  384. /**
  385.  * Regression test
  386.  */
  387. class CRegTestParams : public CChainParams {
  388. public:
  389.     explicit CRegTestParams(const ArgsManager& args) {
  390.         strNetworkID =  CBaseChainParams::REGTEST;
  391.         consensus.signet_blocks = false;
  392.         consensus.signet_challenge.clear();
  393.         consensus.nSubsidyHalvingInterval = 150;
  394.         consensus.BIP16Exception = uint256();
  395.         consensus.BIP34Height = 500; // BIP34 activated on regtest (Used in functional tests)
  396.         consensus.BIP34Hash = uint256();
  397.         consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)
  398.         consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
  399.         consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
  400.         consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
  401.         consensus.MinBIP9WarningHeight = 0;
  402.         consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
  403.         consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
  404.         consensus.nPowTargetSpacing = 10 * 60;
  405.         consensus.fPowAllowMinDifficultyBlocks = true;
  406.         consensus.fPowNoRetargeting = true;
  407.         consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
  408.         consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
  409.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
  410.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
  411.         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
  412.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
  413.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
  414.         consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
  415.  
  416.         consensus.nMinimumChainWork = uint256{};
  417.         consensus.defaultAssumeValid = uint256{};
  418.  
  419.         pchMessageStart[0] = 0xd4;
  420.         pchMessageStart[1] = 0xbf;
  421.         pchMessageStart[2] = 0xf8;
  422.         pchMessageStart[3] = 0xdf;
  423.         nDefaultPort = 18544;
  424.         nPruneAfterHeight = gArgs.GetBoolArg("-fastprune", false) ? 100 : 1000;
  425.         m_assumed_blockchain_size = 0;
  426.         m_assumed_chain_state_size = 0;
  427.  
  428.         UpdateActivationParametersFromArgs(args);
  429.  
  430.         genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
  431.         consensus.hashGenesisBlock = genesis.GetHash();
  432.         assert(consensus.hashGenesisBlock == uint256S("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
  433.         assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
  434.  
  435.         vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
  436.         vSeeds.clear();      //!< Regtest mode doesn't have any DNS seeds.
  437.  
  438.         fDefaultConsistencyChecks = true;
  439.         fRequireStandard = true;
  440.         m_is_test_chain = true;
  441.         m_is_mockable_chain = true;
  442.  
  443.         checkpointData = {
  444.             {
  445.                 {0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")},
  446.             }
  447.         };
  448.  
  449.         m_assumeutxo_data = MapAssumeutxo{
  450.             {
  451.                 110,
  452.                 {uint256S("0x76fd7334ac7c1baf57ddc0c626f073a655a35d98a4258cd1382c8cc2b8392e10"), 110},
  453.             },
  454.             {
  455.                 210,
  456.                 {uint256S("0x9c5ed99ef98544b34f8920b6d1802f72ac28ae6e2bd2bd4c316ff10c230df3f2"), 210},
  457.             },
  458.         };
  459.  
  460.         chainTxData = ChainTxData{
  461.             0,
  462.             0,
  463.             0
  464.         };
  465.  
  466.         base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,107);
  467.         base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,65);
  468.         base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
  469.         base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
  470.         base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
  471.  
  472.         bech32_hrp = "acrt";
  473.     }
  474.  
  475.     /**
  476.      * Allows modifying the Version Bits regtest parameters.
  477.      */
  478.     void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
  479.     {
  480.         consensus.vDeployments[d].nStartTime = nStartTime;
  481.         consensus.vDeployments[d].nTimeout = nTimeout;
  482.     }
  483.     void UpdateActivationParametersFromArgs(const ArgsManager& args);
  484. };
  485.  
  486. void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
  487. {
  488.     if (args.IsArgSet("-segwitheight")) {
  489.         int64_t height = args.GetArg("-segwitheight", consensus.SegwitHeight);
  490.         if (height < -1 || height >= std::numeric_limits<int>::max()) {
  491.             throw std::runtime_error(strprintf("Activation height %ld for segwit is out of valid range. Use -1 to disable segwit.", height));
  492.         } else if (height == -1) {
  493.             LogPrintf("Segwit disabled for testing\n");
  494.             height = std::numeric_limits<int>::max();
  495.         }
  496.         consensus.SegwitHeight = static_cast<int>(height);
  497.     }
  498.  
  499.     if (!args.IsArgSet("-vbparams")) return;
  500.  
  501.     for (const std::string& strDeployment : args.GetArgs("-vbparams")) {
  502.         std::vector<std::string> vDeploymentParams;
  503.         boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":"));
  504.         if (vDeploymentParams.size() != 3) {
  505.             throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end");
  506.         }
  507.         int64_t nStartTime, nTimeout;
  508.         if (!ParseInt64(vDeploymentParams[1], &nStartTime)) {
  509.             throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
  510.         }
  511.         if (!ParseInt64(vDeploymentParams[2], &nTimeout)) {
  512.             throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
  513.         }
  514.         bool found = false;
  515.         for (int j=0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
  516.             if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) {
  517.                 UpdateVersionBitsParameters(Consensus::DeploymentPos(j), nStartTime, nTimeout);
  518.                 found = true;
  519.                 LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld\n", vDeploymentParams[0], nStartTime, nTimeout);
  520.                 break;
  521.             }
  522.         }
  523.         if (!found) {
  524.             throw std::runtime_error(strprintf("Invalid deployment (%s)", vDeploymentParams[0]));
  525.         }
  526.     }
  527. }
  528.  
  529. static std::unique_ptr<const CChainParams> globalChainParams;
  530.  
  531. const CChainParams &Params() {
  532.     assert(globalChainParams);
  533.     return *globalChainParams;
  534. }
  535.  
  536. std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain)
  537. {
  538.     if (chain == CBaseChainParams::MAIN) {
  539.         return std::unique_ptr<CChainParams>(new CMainParams());
  540.     } else if (chain == CBaseChainParams::TESTNET) {
  541.         return std::unique_ptr<CChainParams>(new CTestNetParams());
  542.     } else if (chain == CBaseChainParams::SIGNET) {
  543.         return std::unique_ptr<CChainParams>(new SigNetParams(args));
  544.     } else if (chain == CBaseChainParams::REGTEST) {
  545.         return std::unique_ptr<CChainParams>(new CRegTestParams(args));
  546.     }
  547.     throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
  548. }
  549.  
  550. void SelectParams(const std::string& network)
  551. {
  552.     SelectBaseParams(network);
  553.     globalChainParams = CreateChainParams(gArgs, network);
  554. }
  555.  
  556. std::ostream& operator<<(std::ostream& o, const AssumeutxoData& aud)
  557. {
  558.     o << strprintf("AssumeutxoData(%s, %s)", aud.hash_serialized.ToString(), aud.nChainTx);
  559.     return o;
  560. }
  561.  

Editor

You can edit this paste and save as new:


File Description
  • testcoinhelpforum
  • Paste Code
  • 01 Mar-2021
  • 26.28 Kb
You can Share it: