chainparams.cpp raw

   1  // Copyright (c) 2010 Satoshi Nakamoto
   2  // Copyright (c) 2009-2021 The Limenka 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 <limenka-build-config.h> // IWYU pragma: keep
   7  
   8  #include <kernel/chainparams.h>
   9  
  10  #include <chainparamsseeds.h>
  11  #include <consensus/amount.h>
  12  #include <consensus/merkle.h>
  13  #include <consensus/params.h>
  14  #include <hash.h>
  15  #include <kernel/messagestartchars.h>
  16  #include <logging.h>
  17  #include <primitives/block.h>
  18  #include <primitives/transaction.h>
  19  #include <script/interpreter.h>
  20  #include <script/script.h>
  21  #include <uint256.h>
  22  #include <util/chaintype.h>
  23  #include <util/strencodings.h>
  24  
  25  #include <algorithm>
  26  #include <cassert>
  27  #include <cstdint>
  28  #include <cstring>
  29  #include <type_traits>
  30  
  31  using namespace util::hex_literals;
  32  
  33  RDTSConsentFlag g_rdts_consent{RDTS_CONSENT};
  34  bool g_enable_rdts{g_rdts_consent != RDTSConsentFlag::UNSUPPORTED_UNSAFE_NO_ENFORCEMENT};
  35  bool g_rdts_warning{false};
  36  
  37  // Workaround MSVC bug triggering C7595 when calling consteval constructors in
  38  // initializer lists.
  39  // A fix may be on the way:
  40  // https://developercommunity.visualstudio.com/t/consteval-conversion-function-fails/1579014
  41  #if defined(_MSC_VER)
  42  auto consteval_ctor(auto&& input) { return input; }
  43  #else
  44  #define consteval_ctor(input) (input)
  45  #endif
  46  
  47  static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
  48  {
  49      CMutableTransaction txNew;
  50      txNew.version = 1;
  51      txNew.vin.resize(1);
  52      txNew.vout.resize(1);
  53      txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
  54      txNew.vout[0].nValue = genesisReward;
  55      txNew.vout[0].scriptPubKey = genesisOutputScript;
  56  
  57      CBlock genesis;
  58      genesis.nTime    = nTime;
  59      genesis.nBits    = nBits;
  60      genesis.nNonce   = nNonce;
  61      genesis.nVersion = nVersion;
  62      genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
  63      genesis.hashPrevBlock.SetNull();
  64      genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
  65      return genesis;
  66  }
  67  
  68  /**
  69   * Build the genesis block. Note that the output of its generation
  70   * transaction cannot be spent since it did not originally exist in the
  71   * database.
  72   *
  73   * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
  74   *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
  75   *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
  76   *     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
  77   *   vMerkleTree: 4a5e1e
  78   */
  79  static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
  80  {
  81      const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
  82      const CScript genesisOutputScript = CScript() << "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f"_hex << OP_CHECKSIG;
  83      return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
  84  }
  85  
  86  /**
  87   * Main network on which people trade goods and services.
  88   */
  89  class CMainParams : public CChainParams {
  90  public:
  91      CMainParams() {
  92          m_chain_type = ChainType::MAIN;
  93          consensus.signet_blocks = false;
  94          consensus.signet_challenge.clear();
  95          consensus.nSubsidyHalvingInterval = 210000;
  96          consensus.script_flag_exceptions.emplace( // BIP16 exception
  97              uint256{"00000000000002dc756eebf4f49723ed8d30cc28a5f108eb94b1ba88ac4f9c22"}, SCRIPT_VERIFY_NONE);
  98          consensus.script_flag_exceptions.emplace( // Taproot exception
  99              uint256{"0000000000000000000f14c35b2d841e986ab5441de8c585d5ffe55ea1e395ad"}, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS);
 100          consensus.BIP34Height = 227931;
 101          consensus.BIP34Hash = uint256{"000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"};
 102          consensus.BIP65Height = 388381; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
 103          consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
 104          consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
 105          consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
 106          consensus.MinBIP9WarningHeight = 483840; // segwit activation height + miner confirmation window
 107          consensus.powLimit = uint256{"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"};
 108          consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
 109          consensus.nPowTargetSpacing = 10 * 60;
 110          consensus.fPowAllowMinDifficultyBlocks = false;
 111          consensus.enforce_BIP94 = false;
 112          consensus.fPowNoRetargeting = false;
 113          consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016
 114          consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
 115          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
 116          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 117          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 118          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
 119  
 120          // Deployment of Taproot (BIPs 340-342)
 121          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
 122          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1619222400; // April 24th, 2021
 123          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021
 124          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 709632; // Approximately November 12th, 2021
 125  
 126          // ReducedData Temporary Softfork (RDTS)
 127          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].bit = 4;
 128          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nStartTime = 1764547200; // December 1st, 2025
 129          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 130          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].min_activation_height = 0;
 131          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].max_activation_height = 965664; // ~September 1st, 2026
 132          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].active_duration = std::numeric_limits<int>::max(); // permanent - never expires
 133          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].threshold = 1109; // 55% of 2016
 134  
 135          if (g_rdts_consent == RDTSConsentFlag::UNSUPPORTED_UNSAFE_NO_ENFORCEMENT && !g_enable_rdts) {
 136              consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 137              consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 138              // Do NOT override max_activation_height - keep the flag day so
 139              // non-consenting nodes require blocks to signal RDTS after the
 140              // deadline, staying on the same chain as consenting nodes. Only
 141              // SCRIPT_VERIFY_REDUCED_DATA enforcement differs (g_enable_rdts=false).
 142              // Do NOT zero threshold - the flag day activates regardless, and
 143              // threshold=0 would activate at genesis+2016 causing an earlier chainsplit.
 144          }
 145  
 146          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].bit = 6;
 147          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 148          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 149          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].min_activation_height = 0;
 150  
 151          consensus.nMinimumChainWork = uint256{"0000000000000000000000000000000000000000dee8e2a309ad8a9820433c68"};
 152          consensus.defaultAssumeValid = uint256{"00000000000000000000611fd22f2df7c8fbd0688745c3a6c3bb5109cc2a12cb"}; // 912683
 153  
 154          /**
 155           * The message start string is designed to be unlikely to occur in normal data.
 156           * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
 157           * a large 32-bit integer with any alignment.
 158           */
 159          pchMessageStart[0] = 0xf9;
 160          pchMessageStart[1] = 0xbe;
 161          pchMessageStart[2] = 0xb4;
 162          pchMessageStart[3] = 0xd9;
 163          nDefaultPort = 8333;
 164          nPruneAfterHeight = 100000;
 165          m_assumed_blockchain_size = 810;
 166          m_assumed_chain_state_size = 14;
 167  
 168          genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
 169          consensus.hashGenesisBlock = genesis.GetHash();
 170          assert(consensus.hashGenesisBlock == uint256{"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"});
 171          assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"});
 172  
 173          // Note that of those which support the service bits prefix, most only support a subset of
 174          // possible options.
 175          // This is fine at runtime as we'll fall back to using them as an addrfetch if they don't support the
 176          // service bits we want, but we should get them updated to support all service bits wanted by any
 177          // release ASAP to avoid it where possible.
 178          vSeeds.emplace_back("seed.limenka.sipa.be."); // Pieter Wuille, only supports x1, x5, x9, and xd
 179          vSeeds.emplace_back("dnsseed.bluematt.me."); // Matt Corallo, only supports x9
 180          vSeeds.emplace_back("dnsseed.limenka.dashjr-list-of-p2p-nodes.us."); // Luke Dashjr, support BIP110 seeding (x8000009)
 181          vSeeds.emplace_back("seed.limenka.haf.ovh."); // Léo Haf, support BIP110 seeding (x8000009)
 182          vSeeds.emplace_back("seed.limenka.jonasschnelli.ch."); // Jonas Schnelli, only supports x1, x5, x9, and xd
 183          vSeeds.emplace_back("seed.limenka.sprovoost.nl."); // Sjors Provoost
 184          vSeeds.emplace_back("dnsseed.emzy.de."); // Stephan Oeste
 185          vSeeds.emplace_back("seed.limenka.wiz.biz."); // Jason Maurice
 186          vSeeds.emplace_back("seed.mainnet.achownodes.xyz."); // Ava Chow, only supports x1, x5, x9, x49, x809, x849, xd, x400, x404, x408, x448, xc08, xc48, x40c
 187  
 188          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
 189          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
 190          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,128);
 191          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
 192          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
 193  
 194          bech32_hrp = "bc";
 195  
 196          vFixedSeeds = std::vector<uint8_t>(std::begin(chainparams_seed_main), std::end(chainparams_seed_main));
 197  
 198          fDefaultConsistencyChecks = false;
 199          m_is_mockable_chain = false;
 200  
 201          checkpointData = {
 202              {
 203                  { 11111, uint256{"0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"}},
 204                  { 33333, uint256{"000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"}},
 205                  { 74000, uint256{"0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"}},
 206                  {105000, uint256{"00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"}},
 207                  {134444, uint256{"00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"}},
 208                  {168000, uint256{"000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"}},
 209                  {193000, uint256{"000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317"}},
 210                  {210000, uint256{"000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e"}},
 211                  {216116, uint256{"00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e"}},
 212                  {225430, uint256{"00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932"}},
 213                  {250000, uint256{"000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214"}},
 214                  {279000, uint256{"0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40"}},
 215                  {295000, uint256{"00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983"}},
 216                  {393216, uint256{"00000000000000000390df7d2bdc06b9fcb260b39e3fb15b4bc9f62572553924"}},
 217                  {421888, uint256{"000000000000000004b232ad9492d0729d7f9d6737399ffcdaac1c8160db5ef6"}},
 218                  {438784, uint256{"0000000000000000040d6ef667d7a52caf93d8e0d1e40fd7155c787b42667179"}},
 219                  {451840, uint256{"0000000000000000029103c8ade7786e7379623465c72d71d84624eb9c159bea"}},
 220                  {469766, uint256{"000000000000000000130b2bd812c6a7ae9c02a74fc111806b1dd11e8975da45"}},
 221                  {481824, uint256{"0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893"}},
 222                  {514048, uint256{"00000000000000000022fe630be397a62c58972bb81f0a2d1ae8c968511a4659"}},
 223                  {553472, uint256{"0000000000000000000e06b6698a4f65ab9915f24b23ca2f9d1abf30cc3e9173"}},
 224                  {571392, uint256{"00000000000000000019c18b43077775fc299a6646ab0e9dbbd5770bf6ca392d"}},
 225                  {596000, uint256{"0000000000000000000706f93dc673ca366c810f317e7cfe8d951c0107b65223"}},
 226                  {601723, uint256{"000000000000000000009837f74796532b21d8ccf7def3dcfcb45aa92cd86b9e"}},
 227                  {617056, uint256{"0000000000000000000ca51b293fb2be2fbaf1acc76dcbbbff7e4d7796380b9e"}},
 228                  {632549, uint256{"00000000000000000001bae1b2b73ec3fde475c1ed7fdd382c2c49860ec19920"}},
 229                  {643700, uint256{"00000000000000000002959e9b44507120453344794df09bd1276eb325ed7110"}},
 230                  {667811, uint256{"00000000000000000007888a9d01313d69d6335df46ea33e875ee6832670c596"}},
 231                  {688888, uint256{"0000000000000000000e1e3bd783ce0de7b0cdabf2034723595dbcd5a28cf831"}},
 232                  {704256, uint256{"0000000000000000000465f5acfcd603337994261a4d67a647cb49866c98b538"}},
 233                  {714000, uint256{"0000000000000000000184f9b9da75c3ab764438f4f3ecd766637648a3a44d0d"}},
 234                  {737232, uint256{"0000000000000000000709881cc8d33f84815fe8ea1baad9889042146b4d3042"}},
 235                  {803584, uint256{"000000000000000000003d97a46dbbb4cca4b3e23c39c446df75cfe726163bb5"}},
 236                  {832080, uint256{"00000000000000000003349bda23ed5efc98145c10620c247ec93896ac249e22"}},
 237                  {843264, uint256{"0000000000000000000101209b4ab3570862dc3fac8633eb62938a541c55a2ff"}},
 238                  {846679, uint256{"000000000000000000032b91acdaaf16f8c40d46afeb835c3ac604860f905d56"}},
 239                  {855000, uint256{"0000000000000000000233ea80aa10d38aa4486cd7033fffc2c4df556d0b9138"}},
 240                  {885248, uint256{"000000000000000000006e926737e6a349f7581525ad36e743dfe5f4bc3abbb7"}},
 241                  {908765, uint256{"00000000000000000001b64acb5fe4b40b84092159b6406a6244f46a37fa6c6b"}},
 242              }
 243          };
 244  
 245          m_assumeutxo_data = {
 246              {
 247                  .height = 840'000,
 248                  .hash_serialized = AssumeutxoHash{uint256{"a2a5521b1b5ab65f67818e5e8eccabb7171a517f9e2382208f77687310768f96"}},
 249                  .m_chain_tx_count = 991032194,
 250                  .blockhash = consteval_ctor(uint256{"0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5"}),
 251              },
 252              {
 253                  .height = 880'000,
 254                  .hash_serialized = AssumeutxoHash{uint256{"dbd190983eaf433ef7c15f78a278ae42c00ef52e0fd2a54953782175fbadcea9"}},
 255                  .m_chain_tx_count = 1145604538,
 256                  .blockhash = consteval_ctor(uint256{"000000000000000000010b17283c3c400507969a9c2afd1dcf2082ec5cca2880"}),
 257              },
 258              {
 259                  .height = 910'000,
 260                  .hash_serialized = AssumeutxoHash{uint256{"4daf8a17b4902498c5787966a2b51c613acdab5df5db73f196fa59a4da2f1568"}},
 261                  .m_chain_tx_count = 1226586151,
 262                  .blockhash = consteval_ctor(uint256{"0000000000000000000108970acb9522ffd516eae17acddcb1bd16469194a821"}),
 263              }
 264          };
 265  
 266          chainTxData = ChainTxData{
 267              // Data from RPC: getchaintxstats 4096 00000000000000000000611fd22f2df7c8fbd0688745c3a6c3bb5109cc2a12cb
 268              .nTime    = 1756722903,
 269              .tx_count = 1235299397,
 270              .dTxRate  = 6.721086701157182,  // held back due to present abnormal tx rate
 271          };
 272      }
 273  };
 274  
 275  /**
 276   * Testnet (v3): public test network which is reset from time to time.
 277   */
 278  class CTestNetParams : public CChainParams {
 279  public:
 280      CTestNetParams() {
 281          m_chain_type = ChainType::TESTNET;
 282          consensus.signet_blocks = false;
 283          consensus.signet_challenge.clear();
 284          consensus.nSubsidyHalvingInterval = 210000;
 285          consensus.script_flag_exceptions.emplace( // BIP16 exception
 286              uint256{"00000000dd30457c001f4095d208cc1296b0eed002427aa599874af7a432b105"}, SCRIPT_VERIFY_NONE);
 287          consensus.BIP34Height = 21111;
 288          consensus.BIP34Hash = uint256{"0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8"};
 289          consensus.BIP65Height = 581885; // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
 290          consensus.BIP66Height = 330776; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
 291          consensus.CSVHeight = 770112; // 00000000025e930139bac5c6c31a403776da130831ab85be56578f3fa75369bb
 292          consensus.SegwitHeight = 834624; // 00000000002b980fcd729daaa248fd9316a5200e9b367f4ff2c42453e84201ca
 293          consensus.MinBIP9WarningHeight = 836640; // segwit activation height + miner confirmation window
 294          consensus.powLimit = uint256{"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"};
 295          consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
 296          consensus.nPowTargetSpacing = 10 * 60;
 297          consensus.fPowAllowMinDifficultyBlocks = true;
 298          consensus.enforce_BIP94 = false;
 299          consensus.fPowNoRetargeting = false;
 300          consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
 301          consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
 302          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
 303          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 304          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 305          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
 306  
 307          // Deployment of Taproot (BIPs 340-342)
 308          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
 309          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1619222400; // April 24th, 2021
 310          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021
 311          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
 312  
 313          // ReducedData Temporary Softfork (RDTS)
 314          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].bit = 4;
 315          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nStartTime = 1764547200; // December 1st, 2025
 316          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 317          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].min_activation_height = 0;
 318          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].max_activation_height = std::numeric_limits<int>::max(); // No forced activation; miner signaling only
 319          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].active_duration = std::numeric_limits<int>::max(); // on testnet/signet, permanent if activated
 320          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].threshold = 1109; // 55% of 2016
 321  
 322          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].bit = 6;
 323          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 324          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 325          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].min_activation_height = 0;
 326  
 327          consensus.nMinimumChainWork = uint256{"0000000000000000000000000000000000000000000015f5e0c9f13455b0eb17"};
 328          consensus.defaultAssumeValid = uint256{"00000000000003fc7967410ba2d0a8a8d50daedc318d43e8baf1a9782c236a57"}; // 3974606
 329  
 330          pchMessageStart[0] = 0x0b;
 331          pchMessageStart[1] = 0x11;
 332          pchMessageStart[2] = 0x09;
 333          pchMessageStart[3] = 0x07;
 334          nDefaultPort = 18333;
 335          nPruneAfterHeight = 1000;
 336          m_assumed_blockchain_size = 200;
 337          m_assumed_chain_state_size = 19;
 338  
 339          genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
 340          consensus.hashGenesisBlock = genesis.GetHash();
 341          assert(consensus.hashGenesisBlock == uint256{"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"});
 342          assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"});
 343  
 344          vFixedSeeds.clear();
 345          vSeeds.clear();
 346          // nodes with support for servicebits filtering should be at the top
 347          vSeeds.emplace_back("testnet-seed.limenka.jonasschnelli.ch.");
 348          vSeeds.emplace_back("seed.testnet.limenka.sprovoost.nl.");
 349          vSeeds.emplace_back("testnet-seed.bluematt.me."); // Just a static list of stable node(s), only supports x9
 350          vSeeds.emplace_back("seed.testnet.achownodes.xyz."); // Ava Chow, only supports x1, x5, x9, x49, x809, x849, xd, x400, x404, x408, x448, xc08, xc48, x40c
 351  
 352          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
 353          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
 354          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
 355          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
 356          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
 357  
 358          bech32_hrp = "tb";
 359  
 360          vFixedSeeds = std::vector<uint8_t>(std::begin(chainparams_seed_test), std::end(chainparams_seed_test));
 361  
 362          fDefaultConsistencyChecks = false;
 363          m_is_mockable_chain = false;
 364  
 365          checkpointData = {
 366              {
 367                  {546, uint256{"000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70"}},
 368              }
 369          };
 370  
 371          m_assumeutxo_data = {
 372              {
 373                  .height = 2'500'000,
 374                  .hash_serialized = AssumeutxoHash{uint256{"f841584909f68e47897952345234e37fcd9128cd818f41ee6c3ca68db8071be7"}},
 375                  .m_chain_tx_count = 66484552,
 376                  .blockhash = consteval_ctor(uint256{"0000000000000093bcb68c03a9a168ae252572d348a2eaeba2cdf9231d73206f"}),
 377              }
 378          };
 379  
 380          chainTxData = ChainTxData{
 381              // Data from RPC: getchaintxstats 4096 00000000000003fc7967410ba2d0a8a8d50daedc318d43e8baf1a9782c236a57
 382              .nTime    = 1741042082,
 383              .tx_count = 475477615,
 384              .dTxRate  = 17.15933950357594,
 385          };
 386      }
 387  };
 388  
 389  /**
 390   * Testnet (v4): public test network which is reset from time to time.
 391   */
 392  class CTestNet4Params : public CChainParams {
 393  public:
 394      CTestNet4Params() {
 395          m_chain_type = ChainType::TESTNET4;
 396          consensus.signet_blocks = false;
 397          consensus.signet_challenge.clear();
 398          consensus.nSubsidyHalvingInterval = 210000;
 399          consensus.BIP34Height = 1;
 400          consensus.BIP34Hash = uint256{};
 401          consensus.BIP65Height = 1;
 402          consensus.BIP66Height = 1;
 403          consensus.CSVHeight = 1;
 404          consensus.SegwitHeight = 1;
 405          consensus.MinBIP9WarningHeight = 0;
 406          consensus.powLimit = uint256{"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"};
 407          consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
 408          consensus.nPowTargetSpacing = 10 * 60;
 409          consensus.fPowAllowMinDifficultyBlocks = true;
 410          consensus.enforce_BIP94 = true;
 411          consensus.fPowNoRetargeting = false;
 412          consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
 413          consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
 414          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
 415          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 416          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 417          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
 418  
 419          // Deployment of Taproot (BIPs 340-342)
 420          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
 421          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
 422          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 423          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
 424  
 425          // ReducedData Temporary Softfork (RDTS)
 426          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].bit = 4;
 427          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nStartTime = 1764547200; // December 1st, 2025
 428          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 429          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].min_activation_height = 0;
 430          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].max_activation_height = std::numeric_limits<int>::max(); // No forced activation; miner signaling only
 431          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].active_duration = std::numeric_limits<int>::max(); // on testnet/signet, permanent if activated
 432          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].threshold = 1109; // 55% of 2016
 433  
 434          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].bit = 6;
 435          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 436          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 437          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].min_activation_height = 0;
 438  
 439          consensus.nMinimumChainWork = uint256{"0000000000000000000000000000000000000000000001d6dce8651b6094e4c1"};
 440          consensus.defaultAssumeValid = uint256{"0000000000003ed4f08dbdf6f7d6b271a6bcffce25675cb40aa9fa43179a89f3"}; // 72600
 441  
 442          pchMessageStart[0] = 0x1c;
 443          pchMessageStart[1] = 0x16;
 444          pchMessageStart[2] = 0x3f;
 445          pchMessageStart[3] = 0x28;
 446          nDefaultPort = 48333;
 447          nPruneAfterHeight = 1000;
 448          m_assumed_blockchain_size = 11;
 449          m_assumed_chain_state_size = 1;
 450  
 451          const char* testnet4_genesis_msg = "03/May/2024 000000000000000000001ebd58c244970b3aa9d783bb001011fbe8ea8e98e00e";
 452          const CScript testnet4_genesis_script = CScript() << "000000000000000000000000000000000000000000000000000000000000000000"_hex << OP_CHECKSIG;
 453          genesis = CreateGenesisBlock(testnet4_genesis_msg,
 454                  testnet4_genesis_script,
 455                  1714777860,
 456                  393743547,
 457                  0x1d00ffff,
 458                  1,
 459                  50 * COIN);
 460          consensus.hashGenesisBlock = genesis.GetHash();
 461          assert(consensus.hashGenesisBlock == uint256{"00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043"});
 462          assert(genesis.hashMerkleRoot == uint256{"7aa0a7ae1e223414cb807e40cd57e667b718e42aaf9306db9102fe28912b7b4e"});
 463  
 464          vFixedSeeds.clear();
 465          vSeeds.clear();
 466          // nodes with support for servicebits filtering should be at the top
 467          vSeeds.emplace_back("seed.testnet4.limenka.sprovoost.nl."); // Sjors Provoost
 468          vSeeds.emplace_back("seed.testnet4.wiz.biz."); // Jason Maurice
 469  
 470          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
 471          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
 472          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
 473          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
 474          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
 475  
 476          bech32_hrp = "tb";
 477  
 478          vFixedSeeds = std::vector<uint8_t>(std::begin(chainparams_seed_testnet4), std::end(chainparams_seed_testnet4));
 479  
 480          fDefaultConsistencyChecks = false;
 481          m_is_mockable_chain = false;
 482  
 483          checkpointData = {
 484              {
 485                  {},
 486              }
 487          };
 488  
 489          m_assumeutxo_data = {
 490              {}
 491          };
 492  
 493          chainTxData = ChainTxData{
 494              // Data from RPC: getchaintxstats 4096 0000000000003ed4f08dbdf6f7d6b271a6bcffce25675cb40aa9fa43179a89f3
 495              .nTime    = 1741070246,
 496              .tx_count = 7653966,
 497              .dTxRate  = 1.239174414591965,
 498          };
 499      }
 500  };
 501  
 502  /**
 503   * Signet: test network with an additional consensus parameter (see BIP325).
 504   */
 505  class SigNetParams : public CChainParams {
 506  public:
 507      explicit SigNetParams(const SigNetOptions& options)
 508      {
 509          std::vector<uint8_t> bin;
 510          vFixedSeeds.clear();
 511          vSeeds.clear();
 512  
 513          if (!options.challenge) {
 514              bin = "512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae"_hex_v_u8;
 515              vFixedSeeds = std::vector<uint8_t>(std::begin(chainparams_seed_signet), std::end(chainparams_seed_signet));
 516              vSeeds.emplace_back("seed.signet.limenka.sprovoost.nl.");
 517              vSeeds.emplace_back("seed.signet.achownodes.xyz."); // Ava Chow, only supports x1, x5, x9, x49, x809, x849, xd, x400, x404, x408, x448, xc08, xc48, x40c
 518  
 519              consensus.nMinimumChainWork = uint256{"000000000000000000000000000000000000000000000000000002b517f3d1a1"};
 520              consensus.defaultAssumeValid = uint256{"000000895a110f46e59eb82bbc5bfb67fa314656009c295509c21b4999f5180a"}; // 237722
 521              m_assumed_blockchain_size = 9;
 522              m_assumed_chain_state_size = 1;
 523              chainTxData = ChainTxData{
 524                  // Data from RPC: getchaintxstats 4096 000000895a110f46e59eb82bbc5bfb67fa314656009c295509c21b4999f5180a
 525                  .nTime    = 1741019645,
 526                  .tx_count = 16540736,
 527                  .dTxRate  = 1.064918879911595,
 528              };
 529          } else {
 530              bin = *options.challenge;
 531              consensus.nMinimumChainWork = uint256{};
 532              consensus.defaultAssumeValid = uint256{};
 533              m_assumed_blockchain_size = 0;
 534              m_assumed_chain_state_size = 0;
 535              chainTxData = ChainTxData{
 536                  0,
 537                  0,
 538                  0,
 539              };
 540              LogPrintf("Signet with challenge %s\n", HexStr(bin));
 541          }
 542  
 543          if (options.seeds) {
 544              vSeeds = *options.seeds;
 545          }
 546  
 547          m_chain_type = ChainType::SIGNET;
 548          consensus.signet_blocks = true;
 549          consensus.signet_challenge.assign(bin.begin(), bin.end());
 550          consensus.nSubsidyHalvingInterval = 210000;
 551          consensus.BIP34Height = 1;
 552          consensus.BIP34Hash = uint256{};
 553          consensus.BIP65Height = 1;
 554          consensus.BIP66Height = 1;
 555          consensus.CSVHeight = 1;
 556          consensus.SegwitHeight = 1;
 557          consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
 558          consensus.nPowTargetSpacing = options.pow_target_spacing;
 559          consensus.fPowAllowMinDifficultyBlocks = false;
 560          consensus.enforce_BIP94 = false;
 561          consensus.fPowNoRetargeting = false;
 562          consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016
 563          consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
 564          consensus.MinBIP9WarningHeight = 0;
 565          consensus.powLimit = uint256{"00000377ae000000000000000000000000000000000000000000000000000000"};
 566          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
 567          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 568          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 569          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
 570  
 571          // Activation of Taproot (BIPs 340-342)
 572          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
 573          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
 574          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 575          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
 576  
 577          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].bit = 4;
 578          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 579          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 580          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].min_activation_height = 0;
 581  
 582          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].bit = 6;
 583          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 584          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 585          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].min_activation_height = 0;
 586  
 587          // message start is defined as the first 4 bytes of the sha256d of the block script
 588          HashWriter h{};
 589          h << consensus.signet_challenge;
 590          uint256 hash = h.GetHash();
 591          std::copy_n(hash.begin(), 4, pchMessageStart.begin());
 592  
 593          nDefaultPort = 38333;
 594          nPruneAfterHeight = 1000;
 595  
 596          genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 50 * COIN);
 597          consensus.hashGenesisBlock = genesis.GetHash();
 598          assert(consensus.hashGenesisBlock == uint256{"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"});
 599          assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"});
 600  
 601          m_assumeutxo_data = {
 602              {
 603                  .height = 160'000,
 604                  .hash_serialized = AssumeutxoHash{uint256{"fe0a44309b74d6b5883d246cb419c6221bcccf0b308c9b59b7d70783dbdf928a"}},
 605                  .m_chain_tx_count = 2289496,
 606                  .blockhash = consteval_ctor(uint256{"0000003ca3c99aff040f2563c2ad8f8ec88bd0fd6b8f0895cfaf1ef90353a62c"}),
 607              }
 608          };
 609  
 610          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
 611          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
 612          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
 613          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
 614          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
 615  
 616          bech32_hrp = "tb";
 617  
 618          fDefaultConsistencyChecks = false;
 619          m_is_mockable_chain = false;
 620      }
 621  };
 622  
 623  /**
 624   * Regression test: intended for private networks only. Has minimal difficulty to ensure that
 625   * blocks can be found instantly.
 626   */
 627  class CRegTestParams : public CChainParams
 628  {
 629  public:
 630      explicit CRegTestParams(const RegTestOptions& opts)
 631      {
 632          m_chain_type = ChainType::REGTEST;
 633          consensus.signet_blocks = false;
 634          consensus.signet_challenge.clear();
 635          consensus.nSubsidyHalvingInterval = 150;
 636          consensus.BIP34Height = 1; // Always active unless overridden
 637          consensus.BIP34Hash = uint256();
 638          consensus.BIP65Height = 1;  // Always active unless overridden
 639          consensus.BIP66Height = 1;  // Always active unless overridden
 640          consensus.CSVHeight = 1;    // Always active unless overridden
 641          consensus.SegwitHeight = 0; // Always active unless overridden
 642          consensus.MinBIP9WarningHeight = 0;
 643          consensus.powLimit = uint256{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"};
 644          consensus.nPowTargetTimespan = 24 * 60 * 60; // one day
 645          consensus.nPowTargetSpacing = 10 * 60;
 646          consensus.fPowAllowMinDifficultyBlocks = true;
 647          consensus.enforce_BIP94 = opts.enforce_bip94;
 648          consensus.fPowNoRetargeting = true;
 649          consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
 650          consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
 651  
 652          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
 653          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
 654          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 655          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
 656  
 657          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
 658          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
 659          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 660          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
 661  
 662          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].bit = 4;
 663          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 664          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 665          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].min_activation_height = 0;
 666  
 667          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].bit = 6;
 668          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 669          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 670          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].min_activation_height = 0;
 671  
 672          consensus.nMinimumChainWork = uint256{};
 673          consensus.defaultAssumeValid = uint256{};
 674  
 675          pchMessageStart[0] = 0xfa;
 676          pchMessageStart[1] = 0xbf;
 677          pchMessageStart[2] = 0xb5;
 678          pchMessageStart[3] = 0xda;
 679          nDefaultPort = 18444;
 680          nPruneAfterHeight = opts.fastprune ? 100 : 1000;
 681          m_assumed_blockchain_size = 0;
 682          m_assumed_chain_state_size = 0;
 683  
 684          for (const auto& [dep, height] : opts.activation_heights) {
 685              switch (dep) {
 686              case Consensus::BuriedDeployment::DEPLOYMENT_SEGWIT:
 687                  consensus.SegwitHeight = int{height};
 688                  break;
 689              case Consensus::BuriedDeployment::DEPLOYMENT_HEIGHTINCB:
 690                  consensus.BIP34Height = int{height};
 691                  break;
 692              case Consensus::BuriedDeployment::DEPLOYMENT_DERSIG:
 693                  consensus.BIP66Height = int{height};
 694                  break;
 695              case Consensus::BuriedDeployment::DEPLOYMENT_CLTV:
 696                  consensus.BIP65Height = int{height};
 697                  break;
 698              case Consensus::BuriedDeployment::DEPLOYMENT_CSV:
 699                  consensus.CSVHeight = int{height};
 700                  break;
 701              }
 702          }
 703  
 704          for (const auto& [deployment_pos, version_bits_params] : opts.version_bits_parameters) {
 705              consensus.vDeployments[deployment_pos].nStartTime = version_bits_params.start_time;
 706              consensus.vDeployments[deployment_pos].nTimeout = version_bits_params.timeout;
 707              consensus.vDeployments[deployment_pos].min_activation_height = version_bits_params.min_activation_height;
 708              consensus.vDeployments[deployment_pos].max_activation_height = version_bits_params.max_activation_height;
 709              consensus.vDeployments[deployment_pos].active_duration = version_bits_params.active_duration;
 710              // Validated here rather than in src/chainparams.cpp because nMinerConfirmationWindow is not yet available at parse time
 711              if (version_bits_params.active_duration != std::numeric_limits<int>::max() && version_bits_params.active_duration % consensus.nMinerConfirmationWindow != 0) {
 712                  throw std::runtime_error(strprintf("active_duration (%d) must be a multiple of nMinerConfirmationWindow (%d)", version_bits_params.active_duration, consensus.nMinerConfirmationWindow));
 713              }
 714              consensus.vDeployments[deployment_pos].threshold = version_bits_params.threshold;
 715          }
 716  
 717          genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
 718          consensus.hashGenesisBlock = genesis.GetHash();
 719          assert(consensus.hashGenesisBlock == uint256{"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"});
 720          assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"});
 721  
 722          vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
 723          vSeeds.clear();
 724          vSeeds.emplace_back("dummySeed.invalid.");
 725  
 726          fDefaultConsistencyChecks = true;
 727          m_is_mockable_chain = true;
 728  
 729          checkpointData = {
 730              {
 731                  {0, uint256{"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"}},
 732              }
 733          };
 734  
 735          m_assumeutxo_data = {
 736              {   // For use by unit tests
 737                  .height = 110,
 738                  .hash_serialized = AssumeutxoHash{uint256{"6657b736d4fe4db0cbc796789e812d5dba7f5c143764b1b6905612f1830609d1"}},
 739                  .m_chain_tx_count = 111,
 740                  .blockhash = consteval_ctor(uint256{"696e92821f65549c7ee134edceeeeaaa4105647a3c4fd9f298c0aec0ab50425c"}),
 741              },
 742              {
 743                  // For use by fuzz target src/test/fuzz/utxo_snapshot.cpp
 744                  .height = 200,
 745                  .hash_serialized = AssumeutxoHash{uint256{"4f34d431c3e482f6b0d67b64609ece3964dc8d7976d02ac68dd7c9c1421738f2"}},
 746                  .m_chain_tx_count = 201,
 747                  .blockhash = consteval_ctor(uint256{"5e93653318f294fb5aa339d00bbf8cf1c3515488ad99412c37608b139ea63b27"}),
 748              },
 749              {
 750                  // For use by test/functional/feature_assumeutxo.py
 751                  .height = 299,
 752                  .hash_serialized = AssumeutxoHash{uint256{"a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27"}},
 753                  .m_chain_tx_count = 334,
 754                  .blockhash = consteval_ctor(uint256{"3bb7ce5eba0be48939b7a521ac1ba9316afee2c7bada3a0cca24188e6d7d96c0"}),
 755              },
 756          };
 757  
 758          chainTxData = ChainTxData{
 759              0,
 760              0,
 761              0
 762          };
 763  
 764          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
 765          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
 766          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
 767          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
 768          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
 769  
 770          bech32_hrp = "bcrt";
 771      }
 772  };
 773  
 774  std::unique_ptr<const CChainParams> CChainParams::SigNet(const SigNetOptions& options)
 775  {
 776      return std::make_unique<const SigNetParams>(options);
 777  }
 778  
 779  std::unique_ptr<const CChainParams> CChainParams::RegTest(const RegTestOptions& options)
 780  {
 781      return std::make_unique<const CRegTestParams>(options);
 782  }
 783  
 784  std::unique_ptr<const CChainParams> CChainParams::Main()
 785  {
 786      return std::make_unique<const CMainParams>();
 787  }
 788  
 789  std::unique_ptr<const CChainParams> CChainParams::TestNet()
 790  {
 791      return std::make_unique<const CTestNetParams>();
 792  }
 793  
 794  std::unique_ptr<const CChainParams> CChainParams::TestNet4()
 795  {
 796      return std::make_unique<const CTestNet4Params>();
 797  }
 798  
 799  class CForkParams : public CChainParams
 800  {
 801  public:
 802      CForkParams()
 803      {
 804          m_chain_type = ChainType::FORK;
 805          consensus.signet_blocks = false;
 806          consensus.signet_challenge.clear();
 807          consensus.nSubsidyHalvingInterval = 210000; // 4-year halving by aggregate seconds
 808  
 809          // Inherit mainnet's script flag exceptions (the two blocks that
 810          // violated BIP16 and Taproot).  Without these, the fork rejects those
 811          // blocks and forks off the parent chain.
 812          consensus.script_flag_exceptions.emplace( // BIP16 exception
 813              uint256{"00000000000002dc756eebf4f49723ed8d30cc28a5f108eb94b1ba88ac4f9c22"}, SCRIPT_VERIFY_NONE);
 814          consensus.script_flag_exceptions.emplace( // Taproot exception
 815              uint256{"0000000000000000000f14c35b2d841e986ab5441de8c585d5ffe55ea1e395ad"}, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS);
 816  
 817          // Inherit mainnet's buried soft-fork activation heights.  The fork
 818          // follows parent-chain rules below the MTP activation gate.
 819          consensus.BIP34Height = 227931;
 820          consensus.BIP34Hash = uint256{"000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"};
 821          consensus.BIP65Height = 388381; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
 822          consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
 823          consensus.CSVHeight = 419328;   // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
 824          consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
 825          consensus.MinBIP9WarningHeight = 483840;
 826  
 827          // powLimit: same as mainnet — the fork continues the parent chain's
 828          // 600s cadence and does not reset difficulty at activation.
 829          consensus.powLimit = uint256{"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"};
 830          consensus.nPowTargetTimespan = 14 * 24 * 60 * 60;
 831          consensus.nPowTargetSpacing = 600;
 832          consensus.fPowAllowMinDifficultyBlocks = false;
 833          consensus.enforce_BIP94 = false;
 834          consensus.fPowNoRetargeting = false;
 835          consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016
 836          consensus.nMinerConfirmationWindow = 2016;
 837  
 838          // Fork activation: MTP-based time gate.  The MTP-101 median
 839          // sits ~50 blocks back; nForkActivationBias compensates so the
 840          // fork activates near the intended wall time (handoff sim:
 841          // measured lag ~1.7h vs ~6-8h unbiasied).
 842          consensus.nForkActivationMTP = 1792328400; // 2026-10-18 09:00 EDT, anniversary of Event 201 opening
 843          consensus.nForkActivationBias = 30000;     // 50 blocks * 600s median-lag compensation
 844          consensus.nForkMTPWindow = 101;
 845          consensus.nForkFutureLimit = 60;           // fork blocks: nTime <= now + 60s
 846  
 847          // Single-lane 600s cadence with a PI difficulty controller.
 848          // The setpoint is calibrated above 600 to cancel the
 849          // asymmetric-integral rectification bias (steady-state mean
 850          // lands at ~600s; sims: 601.1s over 10 seeds).
 851          consensus.nForkIntervalTarget = 617;
 852  
 853          // Sequential delay: 2^33 long-division steps, ~60s on the
 854          // reference hardware (measured 6.04 ns/step on Zen 2).
 855          consensus.nForkDelaySteps = 8589934592ull; // 2^33
 856  
 857          // PI gains (corrected naming: P = instantaneous error,
 858          // I = EMA accumulator), scaled by 1e6.  Asymmetric integral:
 859          // raise slowly (flood-proof), lower fast (quick restore).
 860          // Sim-validated: 1000x/2h flood damage 2.5-2.7x, restore
 861          // 7-12h; collapse recovery 8.6-10.1h; 3% rectification
 862          // dilation canceled by the 617s setpoint.
 863          consensus.nForkKp = 10000000;
 864          consensus.nForkKiUp = 5000000;
 865          consensus.nForkKiDown = 50000000;
 866  
 867          // Versionbit deployments: inherit mainnet's Taproot and RDTS so the
 868          // fork follows parent-chain rules below the MTP activation gate.
 869          // P2SPKH is fork-gated (see GetBlockScriptFlags), so it stays NEVER_ACTIVE.
 870          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
 871          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 872          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 873          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0;
 874  
 875          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
 876          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1619222400; // April 24th, 2021
 877          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021
 878          consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 709632; // Approximately November 12th, 2021
 879  
 880          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].bit = 4;
 881          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nStartTime = 1764547200; // December 1st, 2025
 882          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 883          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].min_activation_height = 0;
 884          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].max_activation_height = 965664; // ~September 1st, 2026
 885          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].active_duration = std::numeric_limits<int>::max(); // permanent - never expires
 886          consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].threshold = 1109; // 55% of 2016
 887  
 888          if (g_rdts_consent == RDTSConsentFlag::UNSUPPORTED_UNSAFE_NO_ENFORCEMENT && !g_enable_rdts) {
 889              consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 890              consensus.vDeployments[Consensus::DEPLOYMENT_REDUCED_DATA].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 891          }
 892  
 893          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].bit = 6;
 894          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
 895          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
 896          consensus.vDeployments[Consensus::DEPLOYMENT_P2SPKH].min_activation_height = 0;
 897  
 898          // Genesis: inherited from mainnet for data directory bootstrap.
 899          // Not used for fork consensus — the fork activates at the MTP gate.
 900          // The genesis block here exists only to keep CChainParams valid during init.
 901          genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
 902          consensus.hashGenesisBlock = genesis.GetHash();
 903  
 904          // Inherit mainnet's chain-work and assumevalid so the fork can reuse
 905          // the parent chainstate without re-validating the entire chain.
 906          consensus.nMinimumChainWork = uint256{"0000000000000000000000000000000000000000dee8e2a309ad8a9820433c68"};
 907          consensus.defaultAssumeValid = uint256{"00000000000000000000611fd22f2df7c8fbd0688745c3a6c3bb5109cc2a12cb"}; // 912683
 908  
 909          // Own network identity (decision 7): distinct magic so fork
 910          // blocks never propagate onto the parent network.  Transactions
 911          // are shared by users broadcasting to both networks; the fork
 912          // bootstraps its chainstate from the inherited parent block
 913          // files, not from parent peers.
 914          pchMessageStart[0] = 0xfa;
 915          pchMessageStart[1] = 0xbf;
 916          pchMessageStart[2] = 0xd5;
 917          pchMessageStart[3] = 0xc6;
 918          nDefaultPort = 19444;
 919          nPruneAfterHeight = 100000;
 920          m_assumed_blockchain_size = 810;
 921          m_assumed_chain_state_size = 14;
 922  
 923          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
 924          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
 925          base58Prefixes[SECRET_KEY]     = std::vector<unsigned char>(1,128);
 926          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
 927          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
 928          bech32_hrp = "bf";
 929          vFixedSeeds.clear();
 930          fDefaultConsistencyChecks = false;
 931          m_is_mockable_chain = true;
 932          checkpointData = {
 933              {
 934                  { 11111, uint256{"0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"}},
 935                  { 33333, uint256{"000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"}},
 936                  { 74000, uint256{"0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"}},
 937                  {105000, uint256{"00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"}},
 938                  {134444, uint256{"00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"}},
 939                  {168000, uint256{"000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"}},
 940                  {193000, uint256{"000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317"}},
 941                  {210000, uint256{"000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e"}},
 942                  {216116, uint256{"00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e"}},
 943                  {225430, uint256{"00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932"}},
 944                  {250000, uint256{"000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214"}},
 945                  {279000, uint256{"0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40"}},
 946                  {295000, uint256{"00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983"}},
 947                  {393216, uint256{"00000000000000000390df7d2bdc06b9fcb260b39e3fb15b4bc9f62572553924"}},
 948                  {421888, uint256{"000000000000000004b232ad9492d0729d7f9d6737399ffcdaac1c8160db5ef6"}},
 949                  {438784, uint256{"0000000000000000040d6ef667d7a52caf93d8e0d1e40fd7155c787b42667179"}},
 950                  {451840, uint256{"0000000000000000029103c8ade7786e7379623465c72d71d84624eb9c159bea"}},
 951                  {469766, uint256{"000000000000000000130b2bd812c6a7ae9c02a74fc111806b1dd11e8975da45"}},
 952                  {481824, uint256{"0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893"}},
 953                  {514048, uint256{"00000000000000000022fe630be397a62c58972bb81f0a2d1ae8c968511a4659"}},
 954                  {553472, uint256{"0000000000000000000e06b6698a4f65ab9915f24b23ca2f9d1abf30cc3e9173"}},
 955                  {571392, uint256{"00000000000000000019c18b43077775fc299a6646ab0e9dbbd5770bf6ca392d"}},
 956                  {596000, uint256{"0000000000000000000706f93dc673ca366c810f317e7cfe8d951c0107b65223"}},
 957                  {601723, uint256{"000000000000000000009837f74796532b21d8ccf7def3dcfcb45aa92cd86b9e"}},
 958                  {617056, uint256{"0000000000000000000ca51b293fb2be2fbaf1acc76dcbbbff7e4d7796380b9e"}},
 959                  {632549, uint256{"00000000000000000001bae1b2b73ec3fde475c1ed7fdd382c2c49860ec19920"}},
 960                  {643700, uint256{"00000000000000000002959e9b44507120453344794df09bd1276eb325ed7110"}},
 961                  {667811, uint256{"00000000000000000007888a9d01313d69d6335df46ea33e875ee6832670c596"}},
 962                  {688888, uint256{"0000000000000000000e1e3bd783ce0de7b0cdabf2034723595dbcd5a28cf831"}},
 963                  {704256, uint256{"0000000000000000000465f5acfcd603337994261a4d67a647cb49866c98b538"}},
 964                  {714000, uint256{"0000000000000000000184f9b9da75c3ab764438f4f3ecd766637648a3a44d0d"}},
 965                  {737232, uint256{"0000000000000000000709881cc8d33f84815fe8ea1baad9889042146b4d3042"}},
 966                  {803584, uint256{"000000000000000000003d97a46dbbb4cca4b3e23c39c446df75cfe726163bb5"}},
 967                  {832080, uint256{"00000000000000000003349bda23ed5efc98145c10620c247ec93896ac249e22"}},
 968                  {843264, uint256{"0000000000000000000101209b4ab3570862dc3fac8633eb62938a541c55a2ff"}},
 969                  {846679, uint256{"000000000000000000032b91acdaaf16f8c40d46afeb835c3ac604860f905d56"}},
 970                  {855000, uint256{"0000000000000000000233ea80aa10d38aa4486cd7033fffc2c4df556d0b9138"}},
 971                  {885248, uint256{"000000000000000000006e926737e6a349f7581525ad36e743dfe5f4bc3abbb7"}},
 972                  {908765, uint256{"00000000000000000001b64acb5fe4b40b84092159b6406a6244f46a37fa6c6b"}},
 973              }
 974          };
 975          m_assumeutxo_data = {};
 976          chainTxData = ChainTxData{
 977              // Data from RPC: getchaintxstats 4096 00000000000000000000611fd22f2df7c8fbd0688745c3a6c3bb5109cc2a12cb
 978              .nTime    = 1756722903,
 979              .tx_count = 1235299397,
 980              .dTxRate  = 6.721086701157182,
 981          };
 982      }
 983  };
 984  
 985  std::unique_ptr<const CChainParams> CChainParams::Fork()
 986  {
 987      return std::make_unique<const CForkParams>();
 988  }
 989  
 990  std::vector<int> CChainParams::GetAvailableSnapshotHeights() const
 991  {
 992      std::vector<int> heights;
 993      heights.reserve(m_assumeutxo_data.size());
 994  
 995      for (const auto& data : m_assumeutxo_data) {
 996          heights.emplace_back(data.height);
 997      }
 998      return heights;
 999  }
1000  
1001  std::optional<ChainType> GetNetworkForMagic(const MessageStartChars& message)
1002  {
1003      const auto mainnet_msg = CChainParams::Main()->MessageStart();
1004      const auto testnet_msg = CChainParams::TestNet()->MessageStart();
1005      const auto testnet4_msg = CChainParams::TestNet4()->MessageStart();
1006      const auto regtest_msg = CChainParams::RegTest({})->MessageStart();
1007      const auto signet_msg = CChainParams::SigNet({})->MessageStart();
1008  
1009      const auto fork_msg = CChainParams::Fork()->MessageStart();
1010  
1011      if (std::ranges::equal(message, mainnet_msg)) {
1012          return ChainType::MAIN;
1013      } else if (std::ranges::equal(message, testnet_msg)) {
1014          return ChainType::TESTNET;
1015      } else if (std::ranges::equal(message, testnet4_msg)) {
1016          return ChainType::TESTNET4;
1017      } else if (std::ranges::equal(message, regtest_msg)) {
1018          return ChainType::REGTEST;
1019      } else if (std::ranges::equal(message, signet_msg)) {
1020          return ChainType::SIGNET;
1021      } else if (std::ranges::equal(message, fork_msg)) {
1022          return ChainType::FORK;
1023      }
1024      return std::nullopt;
1025  }
1026