Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
501}503m_chain_type = ChainType::SIGNET;504consensus.signet_blocks = true;505consensus.signet_challenge.assign(bin.begin(), bin.end());506consensus.nSubsidyHalvingInterval = 210000;507consensus.BIP34Height = 1;508consensus.BIP34Hash = uint256{};509consensus.BIP65Height = 1;510consensus.BIP66Height = 1;511consensus.CSVHeight = 1;512consensus.SegwitHeight = 1;513consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks514consensus.nPowTargetSpacing = 10 * 60;515consensus.fPowAllowMinDifficultyBlocks = false;516consensus.enforce_BIP94 = false;517consensus.fPowNoRetargeting = false;518consensus.MinBIP9WarningHeight = 0;519consensus.powLimit = uint256{"00000377ae000000000000000000000000000000000000000000000000000000"};520consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;521consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;522consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;523consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay524consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1815; // 90%525consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;527ApplyDeploymentOptions(options.dep_opts);529// message start is defined as the first 4 bytes of the sha256d of the block script530HashWriter h{};531h << consensus.signet_challenge;532uint256 hash = h.GetHash();533std::copy_n(hash.begin(), 4, pchMessageStart.begin());535nDefaultPort = 38333;536nPruneAfterHeight = 1000;538genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 50 * COIN);539consensus.hashGenesisBlock = genesis.GetHash();540assert(consensus.hashGenesisBlock == uint256{"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"});541assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"});543m_assumeutxo_data = {544{545.height = 160'000,546.hash_serialized = AssumeutxoHash{uint256{"fe0a44309b74d6b5883d246cb419c6221bcccf0b308c9b59b7d70783dbdf928a"}},547.m_chain_tx_count = 2289496,548.blockhash = uint256{"0000003ca3c99aff040f2563c2ad8f8ec88bd0fd6b8f0895cfaf1ef90353a62c"},549},550{551.height = 290'000,552.hash_serialized = AssumeutxoHash{uint256{"97267e000b4b876800167e71b9123f1529d13b14308abec2888bbd2160d14545"}},553.m_chain_tx_count = 28547497,554.blockhash = uint256{"0000000577f2741bb30cd9d39d6d71b023afbeb9764f6260786a97969d5c9ac0"},555},556{557.height = 320'000,558.hash_serialized = AssumeutxoHash{uint256{"1aaf72ecb376cc16957fbb8d5d406bfd6e3165510e2fc83879b6d14cd20b4462"}},559.m_chain_tx_count = 32079110,560.blockhash = uint256{"0000000740ae66b284da84387dcfa14d7b1385b0bad482005ba4e770ea6c4b95"},561}562};564base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);565base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);566base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);567base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};568base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};570bech32_hrp = "tb";572fDefaultConsistencyChecks = false;573m_is_mockable_chain = false;575// Generated by headerssync-params.py on 2026-09-08.576m_headers_sync_params = HeadersSyncParams{577.commitment_period = 629,578.redownload_buffer_size = 15885, // 15885/629 = ~25.3 commitments579};580}581};583/**584* Regression test: intended for private networks only. Has minimal difficulty to ensure that585* blocks can be found instantly.586*/587class CRegTestParams : public CChainParams588{589public:590explicit CRegTestParams(const RegTestOptions& opts)591{592m_chain_type = ChainType::REGTEST;593consensus.signet_blocks = false;594consensus.signet_challenge.clear();595consensus.nSubsidyHalvingInterval = 150;596consensus.BIP34Height = 1; // Always active unless overridden597consensus.BIP34Hash = uint256();598consensus.BIP65Height = 1; // Always active unless overridden599consensus.BIP66Height = 1; // Always active unless overridden600consensus.CSVHeight = 1; // Always active unless overridden601consensus.SegwitHeight = 0; // Always active unless overridden602consensus.MinBIP9WarningHeight = 0;603consensus.powLimit = uint256{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"};604consensus.nPowTargetTimespan = 24 * 60 * 60; // one day605consensus.nPowTargetSpacing = 10 * 60;606consensus.fPowAllowMinDifficultyBlocks = true;607consensus.enforce_BIP94 = opts.enforce_bip94;608consensus.fPowNoRetargeting = true;610consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;611consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;612consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;613consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay614consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 108; // 75%615consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 144; // Faster than normal for regtest (144 instead of 2016)617consensus.nMinimumChainWork = uint256{};618consensus.defaultAssumeValid = uint256{};620pchMessageStart[0] = 0xfa;621pchMessageStart[1] = 0xbf;622pchMessageStart[2] = 0xb5;623pchMessageStart[3] = 0xda;624nDefaultPort = 18444;625nPruneAfterHeight = opts.fastprune ? 100 : 1000;626m_assumed_blockchain_size = 0;627m_assumed_chain_state_size = 0;629ApplyDeploymentOptions(opts.dep_opts);631genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);632consensus.hashGenesisBlock = genesis.GetHash();633assert(consensus.hashGenesisBlock == uint256{"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"});634assert(genesis.hashMerkleRoot == uint256{"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"});636vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.637vSeeds.clear();638vSeeds.emplace_back("dummySeed.invalid.");640fDefaultConsistencyChecks = true;641m_is_mockable_chain = true;643m_assumeutxo_data = {644{ // For use by unit tests645.height = 110,646.hash_serialized = AssumeutxoHash{uint256{"86e9a1205b418b16dde3a18a78c730e30137e28466bda5dbf6b33ab8fc05447c"}},647.m_chain_tx_count = 111,648.blockhash = uint256{"135eec25a6fb277884e5824e7aa7d052c4868161c99a5122170b5266f86c273d"},649},650{651// For use by fuzz target src/test/fuzz/utxo_snapshot.cpp652.height = 200,653.hash_serialized = AssumeutxoHash{uint256{"17dcc016d188d16068907cdeb38b75691a118d43053b8cd6a25969419381d13a"}},654.m_chain_tx_count = 201,655.blockhash = uint256{"385901ccbd69dff6bbd00065d01fb8a9e464dede7cfe0372443884f9b1dcf6b9"},656},657{658// For use by test/functional/feature_assumeutxo.py and test/functional/tool_bitcoin_chainstate.py659.height = 299,660.hash_serialized = AssumeutxoHash{uint256{"106b2c56233e378a824cf0d5ff2be42ed32c72f1605c9be288d00942908a40ac"}},661.m_chain_tx_count = 334,662.blockhash = uint256{"0c552ced4721c249a389eb9b08cb8da261cd46f0e7b5f9d064d48f3113406853"},663},664};666chainTxData = ChainTxData{667.nTime = 0,668.tx_count = 0,669.dTxRate = 0.001, // Set a non-zero rate to make it testable670};672base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);673base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);674base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);675base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};676base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};678bech32_hrp = "bcrt";680// Copied from Testnet4.681m_headers_sync_params = HeadersSyncParams{682.commitment_period = 275,683.redownload_buffer_size = 7017, // 7017/275 = ~25.5 commitments684};685}686};688std::unique_ptr<const CChainParams> CChainParams::SigNet(const SigNetOptions& options)689{690return std::make_unique<const SigNetParams>(options);691}693std::unique_ptr<const CChainParams> CChainParams::RegTest(const RegTestOptions& options)694{695return std::make_unique<const CRegTestParams>(options);696}698std::unique_ptr<const CChainParams> CChainParams::Main(const MainNetOptions& options)699{700return std::make_unique<const CMainParams>(options);701}703std::unique_ptr<const CChainParams> CChainParams::TestNet(const TestNetOptions& options)704{705return std::make_unique<const CTestNetParams>(options);706}708std::unique_ptr<const CChainParams> CChainParams::TestNet4(const TestNetOptions& options)709{710return std::make_unique<const CTestNet4Params>(options);711}713std::vector<int> CChainParams::GetAvailableSnapshotHeights() const714{715std::vector<int> heights;716heights.reserve(m_assumeutxo_data.size());718for (const auto& data : m_assumeutxo_data) {719heights.emplace_back(data.height);720}721return heights;722}724std::optional<ChainType> GetNetworkForMagic(const MessageStartChars& message)725{726const auto mainnet_msg = CChainParams::Main()->MessageStart();727const auto testnet_msg = CChainParams::TestNet()->MessageStart();728const auto testnet4_msg = CChainParams::TestNet4()->MessageStart();729const auto regtest_msg = CChainParams::RegTest()->MessageStart();730const auto signet_msg = CChainParams::SigNet()->MessageStart();732if (std::ranges::equal(message, mainnet_msg)) {733return ChainType::MAIN;734} else if (std::ranges::equal(message, testnet_msg)) {735return ChainType::TESTNET;736} else if (std::ranges::equal(message, testnet4_msg)) {737return ChainType::TESTNET4;738} else if (std::ranges::equal(message, regtest_msg)) {739return ChainType::REGTEST;740} else if (std::ranges::equal(message, signet_msg)) {741return ChainType::SIGNET;742}743return std::nullopt;744}