Branch data Line data Source code
# 1 : : // Copyright (c) 2010 Satoshi Nakamoto
# 2 : : // Copyright (c) 2009-2021 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 <chainparamsbase.h>
# 7 : :
# 8 : : #include <tinyformat.h>
# 9 : : #include <util/system.h>
# 10 : :
# 11 : : #include <assert.h>
# 12 : :
# 13 : : const std::string CBaseChainParams::MAIN = "main";
# 14 : : const std::string CBaseChainParams::TESTNET = "test";
# 15 : : const std::string CBaseChainParams::SIGNET = "signet";
# 16 : : const std::string CBaseChainParams::REGTEST = "regtest";
# 17 : :
# 18 : : void SetupChainParamsBaseOptions(ArgsManager& argsman)
# 19 : 3104 : {
# 20 : 3104 : argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
# 21 : 3104 : argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
# 22 : 3104 : "This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
# 23 : 3104 : argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
# 24 : 3104 : argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
# 25 : 3104 : argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
# 26 : 3104 : argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
# 27 : 3104 : argsman.AddArg("-signetchallenge", "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
# 28 : 3104 : argsman.AddArg("-signetseednode", "Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s))", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
# 29 : 3104 : }
# 30 : :
# 31 : : static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
# 32 : :
# 33 : : const CBaseChainParams& BaseParams()
# 34 : 9965 : {
# 35 : 9965 : assert(globalChainBaseParams);
# 36 : 0 : return *globalChainBaseParams;
# 37 : 9965 : }
# 38 : :
# 39 : : /**
# 40 : : * Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have
# 41 : : * been chosen arbitrarily to keep ranges of used ports tight.
# 42 : : */
# 43 : : std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
# 44 : 16070 : {
# 45 [ + + ]: 16070 : if (chain == CBaseChainParams::MAIN) {
# 46 : 3992 : return std::make_unique<CBaseChainParams>("", 8332, 8334);
# 47 [ + + ]: 12078 : } else if (chain == CBaseChainParams::TESTNET) {
# 48 : 3252 : return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334);
# 49 [ + + ]: 8826 : } else if (chain == CBaseChainParams::SIGNET) {
# 50 : 3270 : return std::make_unique<CBaseChainParams>("signet", 38332, 38334);
# 51 [ + - ]: 5556 : } else if (chain == CBaseChainParams::REGTEST) {
# 52 : 5556 : return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
# 53 : 5556 : }
# 54 : 0 : throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
# 55 : 16070 : }
# 56 : :
# 57 : : void SelectBaseParams(const std::string& chain)
# 58 : 3922 : {
# 59 : 3922 : globalChainBaseParams = CreateBaseChainParams(chain);
# 60 : 3922 : gArgs.SelectConfigNetwork(chain);
# 61 : 3922 : }
|