LCOV - code coverage report
Current view: top level - src - chainparams.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 303 338 89.6 %
Date: 2020-08-11 15:24:34 Functions: 9 10 90.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 0 0 -

           Branch data     Line data    Source code
#       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 <tinyformat.h>
#      11                 :            : #include <util/system.h>
#      12                 :            : #include <util/strencodings.h>
#      13                 :            : #include <versionbitsinfo.h>
#      14                 :            : 
#      15                 :            : #include <assert.h>
#      16                 :            : 
#      17                 :            : #include <boost/algorithm/string/classification.hpp>
#      18                 :            : #include <boost/algorithm/string/split.hpp>
#      19                 :            : 
#      20                 :            : static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
#      21                 :       5923 : {
#      22                 :       5923 :     CMutableTransaction txNew;
#      23                 :       5923 :     txNew.nVersion = 1;
#      24                 :       5923 :     txNew.vin.resize(1);
#      25                 :       5923 :     txNew.vout.resize(1);
#      26                 :       5923 :     txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
#      27                 :       5923 :     txNew.vout[0].nValue = genesisReward;
#      28                 :       5923 :     txNew.vout[0].scriptPubKey = genesisOutputScript;
#      29                 :       5923 : 
#      30                 :       5923 :     CBlock genesis;
#      31                 :       5923 :     genesis.nTime    = nTime;
#      32                 :       5923 :     genesis.nBits    = nBits;
#      33                 :       5923 :     genesis.nNonce   = nNonce;
#      34                 :       5923 :     genesis.nVersion = nVersion;
#      35                 :       5923 :     genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
#      36                 :       5923 :     genesis.hashPrevBlock.SetNull();
#      37                 :       5923 :     genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
#      38                 :       5923 :     return genesis;
#      39                 :       5923 : }
#      40                 :            : 
#      41                 :            : /**
#      42                 :            :  * Build the genesis block. Note that the output of its generation
#      43                 :            :  * transaction cannot be spent since it did not originally exist in the
#      44                 :            :  * database.
#      45                 :            :  *
#      46                 :            :  * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
#      47                 :            :  *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
#      48                 :            :  *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
#      49                 :            :  *     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
#      50                 :            :  *   vMerkleTree: 4a5e1e
#      51                 :            :  */
#      52                 :            : static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
#      53                 :       5923 : {
#      54                 :       5923 :     const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
#      55                 :       5923 :     const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
#      56                 :       5923 :     return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
#      57                 :       5923 : }
#      58                 :            : 
#      59                 :            : /**
#      60                 :            :  * Main network
#      61                 :            :  */
#      62                 :            : class CMainParams : public CChainParams {
#      63                 :            : public:
#      64                 :       2290 :     CMainParams() {
#      65                 :       2290 :         strNetworkID = CBaseChainParams::MAIN;
#      66                 :       2290 :         consensus.nSubsidyHalvingInterval = 210000;
#      67                 :       2290 :         consensus.BIP16Exception = uint256S("0x00000000000002dc756eebf4f49723ed8d30cc28a5f108eb94b1ba88ac4f9c22");
#      68                 :       2290 :         consensus.BIP34Height = 227931;
#      69                 :       2290 :         consensus.BIP34Hash = uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
#      70                 :       2290 :         consensus.BIP65Height = 388381; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
#      71                 :       2290 :         consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
#      72                 :       2290 :         consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
#      73                 :       2290 :         consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
#      74                 :       2290 :         consensus.MinBIP9WarningHeight = 483840; // segwit activation height + miner confirmation window
#      75                 :       2290 :         consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
#      76                 :       2290 :         consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
#      77                 :       2290 :         consensus.nPowTargetSpacing = 10 * 60;
#      78                 :       2290 :         consensus.fPowAllowMinDifficultyBlocks = false;
#      79                 :       2290 :         consensus.fPowNoRetargeting = false;
#      80                 :       2290 :         consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
#      81                 :       2290 :         consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
#      82                 :       2290 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
#      83                 :       2290 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
#      84                 :       2290 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
#      85                 :       2290 : 
#      86                 :       2290 :         // The best chain should have at least this much work.
#      87                 :       2290 :         consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000e1ab5ec9348e9f4b8eb8154");
#      88                 :       2290 : 
#      89                 :       2290 :         // By default assume that the signatures in ancestors of this block are valid.
#      90                 :       2290 :         consensus.defaultAssumeValid = uint256S("0x0000000000000000000f2adce67e49b0b6bdeb9de8b7c3d7e93b21e7fc1e819d"); // 623950
#      91                 :       2290 : 
#      92                 :       2290 :         /**
#      93                 :       2290 :          * The message start string is designed to be unlikely to occur in normal data.
#      94                 :       2290 :          * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
#      95                 :       2290 :          * a large 32-bit integer with any alignment.
#      96                 :       2290 :          */
#      97                 :       2290 :         pchMessageStart[0] = 0xf9;
#      98                 :       2290 :         pchMessageStart[1] = 0xbe;
#      99                 :       2290 :         pchMessageStart[2] = 0xb4;
#     100                 :       2290 :         pchMessageStart[3] = 0xd9;
#     101                 :       2290 :         nDefaultPort = 8333;
#     102                 :       2290 :         nPruneAfterHeight = 100000;
#     103                 :       2290 :         m_assumed_blockchain_size = 320;
#     104                 :       2290 :         m_assumed_chain_state_size = 4;
#     105                 :       2290 : 
#     106                 :       2290 :         genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
#     107                 :       2290 :         consensus.hashGenesisBlock = genesis.GetHash();
#     108                 :       2290 :         assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
#     109                 :       2290 :         assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
#     110                 :       2290 : 
#     111                 :       2290 :         // Note that of those which support the service bits prefix, most only support a subset of
#     112                 :       2290 :         // possible options.
#     113                 :       2290 :         // This is fine at runtime as we'll fall back to using them as an addrfetch if they don't support the
#     114                 :       2290 :         // service bits we want, but we should get them updated to support all service bits wanted by any
#     115                 :       2290 :         // release ASAP to avoid it where possible.
#     116                 :       2290 :         vSeeds.emplace_back("seed.bitcoin.sipa.be"); // Pieter Wuille, only supports x1, x5, x9, and xd
#     117                 :       2290 :         vSeeds.emplace_back("dnsseed.bluematt.me"); // Matt Corallo, only supports x9
#     118                 :       2290 :         vSeeds.emplace_back("dnsseed.bitcoin.dashjr.org"); // Luke Dashjr
#     119                 :       2290 :         vSeeds.emplace_back("seed.bitcoinstats.com"); // Christian Decker, supports x1 - xf
#     120                 :       2290 :         vSeeds.emplace_back("seed.bitcoin.jonasschnelli.ch"); // Jonas Schnelli, only supports x1, x5, x9, and xd
#     121                 :       2290 :         vSeeds.emplace_back("seed.btc.petertodd.org"); // Peter Todd, only supports x1, x5, x9, and xd
#     122                 :       2290 :         vSeeds.emplace_back("seed.bitcoin.sprovoost.nl"); // Sjors Provoost
#     123                 :       2290 :         vSeeds.emplace_back("dnsseed.emzy.de"); // Stephan Oeste
#     124                 :       2290 :         vSeeds.emplace_back("seed.bitcoin.wiz.biz"); // Jason Maurice
#     125                 :       2290 : 
#     126                 :       2290 :         base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
#     127                 :       2290 :         base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
#     128                 :       2290 :         base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,128);
#     129                 :       2290 :         base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
#     130                 :       2290 :         base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
#     131                 :       2290 : 
#     132                 :       2290 :         bech32_hrp = "bc";
#     133                 :       2290 : 
#     134                 :       2290 :         vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
#     135                 :       2290 : 
#     136                 :       2290 :         fDefaultConsistencyChecks = false;
#     137                 :       2290 :         fRequireStandard = true;
#     138                 :       2290 :         m_is_test_chain = false;
#     139                 :       2290 :         m_is_mockable_chain = false;
#     140                 :       2290 : 
#     141                 :       2290 :         checkpointData = {
#     142                 :       2290 :             {
#     143                 :       2290 :                 { 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")},
#     144                 :       2290 :                 { 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")},
#     145                 :       2290 :                 { 74000, uint256S("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")},
#     146                 :       2290 :                 {105000, uint256S("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")},
#     147                 :       2290 :                 {134444, uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")},
#     148                 :       2290 :                 {168000, uint256S("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763")},
#     149                 :       2290 :                 {193000, uint256S("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317")},
#     150                 :       2290 :                 {210000, uint256S("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e")},
#     151                 :       2290 :                 {216116, uint256S("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e")},
#     152                 :       2290 :                 {225430, uint256S("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932")},
#     153                 :       2290 :                 {250000, uint256S("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214")},
#     154                 :       2290 :                 {279000, uint256S("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40")},
#     155                 :       2290 :                 {295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983")},
#     156                 :       2290 :             }
#     157                 :       2290 :         };
#     158                 :       2290 : 
#     159                 :       2290 :         chainTxData = ChainTxData{
#     160                 :       2290 :             // Data from RPC: getchaintxstats 4096 0000000000000000000f2adce67e49b0b6bdeb9de8b7c3d7e93b21e7fc1e819d
#     161                 :       2290 :             /* nTime    */ 1585764811,
#     162                 :       2290 :             /* nTxCount */ 517186863,
#     163                 :       2290 :             /* dTxRate  */ 3.305709665792344,
#     164                 :       2290 :         };
#     165                 :       2290 :     }
#     166                 :            : };
#     167                 :            : 
#     168                 :            : /**
#     169                 :            :  * Testnet (v3)
#     170                 :            :  */
#     171                 :            : class CTestNetParams : public CChainParams {
#     172                 :            : public:
#     173                 :       1540 :     CTestNetParams() {
#     174                 :       1540 :         strNetworkID = CBaseChainParams::TESTNET;
#     175                 :       1540 :         consensus.nSubsidyHalvingInterval = 210000;
#     176                 :       1540 :         consensus.BIP16Exception = uint256S("0x00000000dd30457c001f4095d208cc1296b0eed002427aa599874af7a432b105");
#     177                 :       1540 :         consensus.BIP34Height = 21111;
#     178                 :       1540 :         consensus.BIP34Hash = uint256S("0x0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8");
#     179                 :       1540 :         consensus.BIP65Height = 581885; // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
#     180                 :       1540 :         consensus.BIP66Height = 330776; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
#     181                 :       1540 :         consensus.CSVHeight = 770112; // 00000000025e930139bac5c6c31a403776da130831ab85be56578f3fa75369bb
#     182                 :       1540 :         consensus.SegwitHeight = 834624; // 00000000002b980fcd729daaa248fd9316a5200e9b367f4ff2c42453e84201ca
#     183                 :       1540 :         consensus.MinBIP9WarningHeight = 836640; // segwit activation height + miner confirmation window
#     184                 :       1540 :         consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
#     185                 :       1540 :         consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
#     186                 :       1540 :         consensus.nPowTargetSpacing = 10 * 60;
#     187                 :       1540 :         consensus.fPowAllowMinDifficultyBlocks = true;
#     188                 :       1540 :         consensus.fPowNoRetargeting = false;
#     189                 :       1540 :         consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
#     190                 :       1540 :         consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
#     191                 :       1540 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
#     192                 :       1540 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
#     193                 :       1540 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
#     194                 :       1540 : 
#     195                 :       1540 :         // The best chain should have at least this much work.
#     196                 :       1540 :         consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000001495c1d5a01e2af8a23");
#     197                 :       1540 : 
#     198                 :       1540 :         // By default assume that the signatures in ancestors of this block are valid.
#     199                 :       1540 :         consensus.defaultAssumeValid = uint256S("0x000000000000056c49030c174179b52a928c870e6e8a822c75973b7970cfbd01"); // 1692000
#     200                 :       1540 : 
#     201                 :       1540 :         pchMessageStart[0] = 0x0b;
#     202                 :       1540 :         pchMessageStart[1] = 0x11;
#     203                 :       1540 :         pchMessageStart[2] = 0x09;
#     204                 :       1540 :         pchMessageStart[3] = 0x07;
#     205                 :       1540 :         nDefaultPort = 18333;
#     206                 :       1540 :         nPruneAfterHeight = 1000;
#     207                 :       1540 :         m_assumed_blockchain_size = 40;
#     208                 :       1540 :         m_assumed_chain_state_size = 2;
#     209                 :       1540 : 
#     210                 :       1540 :         genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
#     211                 :       1540 :         consensus.hashGenesisBlock = genesis.GetHash();
#     212                 :       1540 :         assert(consensus.hashGenesisBlock == uint256S("0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"));
#     213                 :       1540 :         assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
#     214                 :       1540 : 
#     215                 :       1540 :         vFixedSeeds.clear();
#     216                 :       1540 :         vSeeds.clear();
#     217                 :       1540 :         // nodes with support for servicebits filtering should be at the top
#     218                 :       1540 :         vSeeds.emplace_back("testnet-seed.bitcoin.jonasschnelli.ch");
#     219                 :       1540 :         vSeeds.emplace_back("seed.tbtc.petertodd.org");
#     220                 :       1540 :         vSeeds.emplace_back("seed.testnet.bitcoin.sprovoost.nl");
#     221                 :       1540 :         vSeeds.emplace_back("testnet-seed.bluematt.me"); // Just a static list of stable node(s), only supports x9
#     222                 :       1540 : 
#     223                 :       1540 :         base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
#     224                 :       1540 :         base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
#     225                 :       1540 :         base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
#     226                 :       1540 :         base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
#     227                 :       1540 :         base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
#     228                 :       1540 : 
#     229                 :       1540 :         bech32_hrp = "tb";
#     230                 :       1540 : 
#     231                 :       1540 :         vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
#     232                 :       1540 : 
#     233                 :       1540 :         fDefaultConsistencyChecks = false;
#     234                 :       1540 :         fRequireStandard = false;
#     235                 :       1540 :         m_is_test_chain = true;
#     236                 :       1540 :         m_is_mockable_chain = false;
#     237                 :       1540 : 
#     238                 :       1540 :         checkpointData = {
#     239                 :       1540 :             {
#     240                 :       1540 :                 {546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")},
#     241                 :       1540 :             }
#     242                 :       1540 :         };
#     243                 :       1540 : 
#     244                 :       1540 :         chainTxData = ChainTxData{
#     245                 :       1540 :             // Data from RPC: getchaintxstats 4096 000000000000056c49030c174179b52a928c870e6e8a822c75973b7970cfbd01
#     246                 :       1540 :             /* nTime    */ 1585561140,
#     247                 :       1540 :             /* nTxCount */ 13483,
#     248                 :       1540 :             /* dTxRate  */ 0.08523187013249722,
#     249                 :       1540 :         };
#     250                 :       1540 :     }
#     251                 :            : };
#     252                 :            : 
#     253                 :            : /**
#     254                 :            :  * Regression test
#     255                 :            :  */
#     256                 :            : class CRegTestParams : public CChainParams {
#     257                 :            : public:
#     258                 :       2093 :     explicit CRegTestParams(const ArgsManager& args) {
#     259                 :       2093 :         strNetworkID =  CBaseChainParams::REGTEST;
#     260                 :       2093 :         consensus.nSubsidyHalvingInterval = 150;
#     261                 :       2093 :         consensus.BIP16Exception = uint256();
#     262                 :       2093 :         consensus.BIP34Height = 500; // BIP34 activated on regtest (Used in functional tests)
#     263                 :       2093 :         consensus.BIP34Hash = uint256();
#     264                 :       2093 :         consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)
#     265                 :       2093 :         consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
#     266                 :       2093 :         consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
#     267                 :       2093 :         consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
#     268                 :       2093 :         consensus.MinBIP9WarningHeight = 0;
#     269                 :       2093 :         consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
#     270                 :       2093 :         consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
#     271                 :       2093 :         consensus.nPowTargetSpacing = 10 * 60;
#     272                 :       2093 :         consensus.fPowAllowMinDifficultyBlocks = true;
#     273                 :       2093 :         consensus.fPowNoRetargeting = true;
#     274                 :       2093 :         consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
#     275                 :       2093 :         consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
#     276                 :       2093 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
#     277                 :       2093 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
#     278                 :       2093 :         consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
#     279                 :       2093 : 
#     280                 :       2093 :         // The best chain should have at least this much work.
#     281                 :       2093 :         consensus.nMinimumChainWork = uint256S("0x00");
#     282                 :       2093 : 
#     283                 :       2093 :         // By default assume that the signatures in ancestors of this block are valid.
#     284                 :       2093 :         consensus.defaultAssumeValid = uint256S("0x00");
#     285                 :       2093 : 
#     286                 :       2093 :         pchMessageStart[0] = 0xfa;
#     287                 :       2093 :         pchMessageStart[1] = 0xbf;
#     288                 :       2093 :         pchMessageStart[2] = 0xb5;
#     289                 :       2093 :         pchMessageStart[3] = 0xda;
#     290                 :       2093 :         nDefaultPort = 18444;
#     291                 :       2093 :         nPruneAfterHeight = 1000;
#     292                 :       2093 :         m_assumed_blockchain_size = 0;
#     293                 :       2093 :         m_assumed_chain_state_size = 0;
#     294                 :       2093 : 
#     295                 :       2093 :         UpdateActivationParametersFromArgs(args);
#     296                 :       2093 : 
#     297                 :       2093 :         genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
#     298                 :       2093 :         consensus.hashGenesisBlock = genesis.GetHash();
#     299                 :       2093 :         assert(consensus.hashGenesisBlock == uint256S("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
#     300                 :       2093 :         assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
#     301                 :       2093 : 
#     302                 :       2093 :         vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
#     303                 :       2093 :         vSeeds.clear();      //!< Regtest mode doesn't have any DNS seeds.
#     304                 :       2093 : 
#     305                 :       2093 :         fDefaultConsistencyChecks = true;
#     306                 :       2093 :         fRequireStandard = true;
#     307                 :       2093 :         m_is_test_chain = true;
#     308                 :       2093 :         m_is_mockable_chain = true;
#     309                 :       2093 : 
#     310                 :       2093 :         checkpointData = {
#     311                 :       2093 :             {
#     312                 :       2093 :                 {0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")},
#     313                 :       2093 :             }
#     314                 :       2093 :         };
#     315                 :       2093 : 
#     316                 :       2093 :         chainTxData = ChainTxData{
#     317                 :       2093 :             0,
#     318                 :       2093 :             0,
#     319                 :       2093 :             0
#     320                 :       2093 :         };
#     321                 :       2093 : 
#     322                 :       2093 :         base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
#     323                 :       2093 :         base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
#     324                 :       2093 :         base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
#     325                 :       2093 :         base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
#     326                 :       2093 :         base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
#     327                 :       2093 : 
#     328                 :       2093 :         bech32_hrp = "bcrt";
#     329                 :       2093 :     }
#     330                 :            : 
#     331                 :            :     /**
#     332                 :            :      * Allows modifying the Version Bits regtest parameters.
#     333                 :            :      */
#     334                 :            :     void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
#     335                 :          0 :     {
#     336                 :          0 :         consensus.vDeployments[d].nStartTime = nStartTime;
#     337                 :          0 :         consensus.vDeployments[d].nTimeout = nTimeout;
#     338                 :          0 :     }
#     339                 :            :     void UpdateActivationParametersFromArgs(const ArgsManager& args);
#     340                 :            : };
#     341                 :            : 
#     342                 :            : void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
#     343                 :       2093 : {
#     344                 :       2093 :     if (gArgs.IsArgSet("-segwitheight")) {
#     345                 :        865 :         int64_t height = gArgs.GetArg("-segwitheight", consensus.SegwitHeight);
#     346                 :        865 :         if (height < -1 || height >= std::numeric_limits<int>::max()) {
#     347                 :          0 :             throw std::runtime_error(strprintf("Activation height %ld for segwit is out of valid range. Use -1 to disable segwit.", height));
#     348                 :        865 :         } else if (height == -1) {
#     349                 :          1 :             LogPrintf("Segwit disabled for testing\n");
#     350                 :          1 :             height = std::numeric_limits<int>::max();
#     351                 :          1 :         }
#     352                 :        865 :         consensus.SegwitHeight = static_cast<int>(height);
#     353                 :        865 :     }
#     354                 :       2093 : 
#     355                 :       2093 :     if (!args.IsArgSet("-vbparams")) return;
#     356                 :          0 : 
#     357                 :          0 :     for (const std::string& strDeployment : args.GetArgs("-vbparams")) {
#     358                 :          0 :         std::vector<std::string> vDeploymentParams;
#     359                 :          0 :         boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":"));
#     360                 :          0 :         if (vDeploymentParams.size() != 3) {
#     361                 :          0 :             throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end");
#     362                 :          0 :         }
#     363                 :          0 :         int64_t nStartTime, nTimeout;
#     364                 :          0 :         if (!ParseInt64(vDeploymentParams[1], &nStartTime)) {
#     365                 :          0 :             throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
#     366                 :          0 :         }
#     367                 :          0 :         if (!ParseInt64(vDeploymentParams[2], &nTimeout)) {
#     368                 :          0 :             throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
#     369                 :          0 :         }
#     370                 :          0 :         bool found = false;
#     371                 :          0 :         for (int j=0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
#     372                 :          0 :             if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) {
#     373                 :          0 :                 UpdateVersionBitsParameters(Consensus::DeploymentPos(j), nStartTime, nTimeout);
#     374                 :          0 :                 found = true;
#     375                 :          0 :                 LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld\n", vDeploymentParams[0], nStartTime, nTimeout);
#     376                 :          0 :                 break;
#     377                 :          0 :             }
#     378                 :          0 :         }
#     379                 :          0 :         if (!found) {
#     380                 :          0 :             throw std::runtime_error(strprintf("Invalid deployment (%s)", vDeploymentParams[0]));
#     381                 :          0 :         }
#     382                 :          0 :     }
#     383                 :          0 : }
#     384                 :            : 
#     385                 :            : static std::unique_ptr<const CChainParams> globalChainParams;
#     386                 :            : 
#     387                 :     964656 : const CChainParams &Params() {
#     388                 :     964656 :     assert(globalChainParams);
#     389                 :     964656 :     return *globalChainParams;
#     390                 :     964656 : }
#     391                 :            : 
#     392                 :            : std::unique_ptr<const CChainParams> CreateChainParams(const std::string& chain)
#     393                 :       5923 : {
#     394                 :       5923 :     if (chain == CBaseChainParams::MAIN)
#     395                 :       2290 :         return std::unique_ptr<CChainParams>(new CMainParams());
#     396                 :       3633 :     else if (chain == CBaseChainParams::TESTNET)
#     397                 :       1540 :         return std::unique_ptr<CChainParams>(new CTestNetParams());
#     398                 :       2093 :     else if (chain == CBaseChainParams::REGTEST)
#     399                 :       2093 :         return std::unique_ptr<CChainParams>(new CRegTestParams(gArgs));
#     400                 :          0 :     throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
#     401                 :          0 : }
#     402                 :            : 
#     403                 :            : void SelectParams(const std::string& network)
#     404                 :       1956 : {
#     405                 :       1956 :     SelectBaseParams(network);
#     406                 :       1956 :     globalChainParams = CreateChainParams(network);
#     407                 :       1956 : }

Generated by: LCOV version 1.14