Bitcoin Core 22.99.0
P2P Digital Currency
chainparamsbase.cpp
Go to the documentation of this file.
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 <chainparamsbase.h>
7
8#include <tinyformat.h>
9#include <util/system.h>
10
11#include <assert.h>
12
13const std::string CBaseChainParams::MAIN = "main";
14const std::string CBaseChainParams::TESTNET = "test";
15const std::string CBaseChainParams::SIGNET = "signet";
16const std::string CBaseChainParams::REGTEST = "regtest";
17
19{
20 argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
21 argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
22 "This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
23 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 argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
25 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 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 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 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}
30
31static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
32
34{
37}
38
43std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
44{
45 if (chain == CBaseChainParams::MAIN) {
46 return std::make_unique<CBaseChainParams>("", 8332, 8334);
47 } else if (chain == CBaseChainParams::TESTNET) {
48 return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334);
49 } else if (chain == CBaseChainParams::SIGNET) {
50 return std::make_unique<CBaseChainParams>("signet", 38332, 38334);
51 } else if (chain == CBaseChainParams::REGTEST) {
52 return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
53 }
54 throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
55}
56
57void SelectBaseParams(const std::string& chain)
58{
61}
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have been chosen arbitrarily to...
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
static std::unique_ptr< CBaseChainParams > globalChainBaseParams
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
void SelectBaseParams(const std::string &chain)
Sets the params returned by Params() to those for the given network.
@ ALLOW_ANY
disable validation
Definition: system.h:166
@ DISALLOW_NEGATION
disallow -nofoo syntax
Definition: system.h:171
@ DEBUG_ONLY
Definition: system.h:173
void SelectConfigNetwork(const std::string &network)
Select the network in use.
Definition: system.cpp:302
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:642
CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) of a given ins...
static const std::string REGTEST
static const std::string TESTNET
static const std::string SIGNET
static const std::string MAIN
Chain name strings.
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
ArgsManager gArgs
Definition: system.cpp:85
assert(!tx.IsCoinBase())