Inside Bitcoin
Opening the selected file…
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.
1// Copyright (c) 2023-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <util/chaintype.h>7#include <util/check.h>9#include <optional>10#include <string>12std::string ChainTypeToString(ChainType chain)13{14switch (chain) {15case ChainType::MAIN:16return "main";17case ChainType::TESTNET:18return "test";19case ChainType::TESTNET4:20return "testnet4";21case ChainType::SIGNET:22return "signet";23case ChainType::REGTEST:24return "regtest";25}26assert(false);27}29std::optional<ChainType> ChainTypeFromString(std::string_view chain)30{31if (chain == "main") {32return ChainType::MAIN;33} else if (chain == "test") {34return ChainType::TESTNET;35} else if (chain == "testnet4") {36return ChainType::TESTNET4;37} else if (chain == "signet") {38return ChainType::SIGNET;39} else if (chain == "regtest") {40return ChainType::REGTEST;41} else {42return std::nullopt;43}44}