24 const auto signet_challenge =
args.
GetArgs(
"-signetchallenge");
25 if (signet_challenge.size() != 1) {
26 throw std::runtime_error(
strprintf(
"%s: -signetchallenge cannot be multiple values.", __func__));
36 for (
const std::string& arg :
args.
GetArgs(
"-testactivationheight")) {
37 const auto found{arg.find(
'@')};
38 if (found == std::string::npos) {
39 throw std::runtime_error(
strprintf(
"Invalid format (%s) for -testactivationheight=name@height.", arg));
42 const auto value{arg.substr(found + 1)};
44 if (!
ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits<int>::max()) {
45 throw std::runtime_error(
strprintf(
"Invalid height value (%s) for -testactivationheight=name@height.", arg));
48 const auto deployment_name{arg.substr(0, found)};
52 throw std::runtime_error(
strprintf(
"Invalid name (%s) for -testactivationheight=name@height.", arg));
58 for (
const std::string& strDeployment :
args.
GetArgs(
"-vbparams")) {
59 std::vector<std::string> vDeploymentParams =
SplitString(strDeployment,
':');
60 if (vDeploymentParams.size() < 3 || 4 < vDeploymentParams.size()) {
61 throw std::runtime_error(
"Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
64 if (!
ParseInt64(vDeploymentParams[1], &vbparams.start_time)) {
65 throw std::runtime_error(
strprintf(
"Invalid nStartTime (%s)", vDeploymentParams[1]));
67 if (!
ParseInt64(vDeploymentParams[2], &vbparams.timeout)) {
68 throw std::runtime_error(
strprintf(
"Invalid nTimeout (%s)", vDeploymentParams[2]));
70 if (vDeploymentParams.size() >= 4) {
71 if (!
ParseInt32(vDeploymentParams[3], &vbparams.min_activation_height)) {
72 throw std::runtime_error(
strprintf(
"Invalid min_activation_height (%s)", vDeploymentParams[3]));
75 vbparams.min_activation_height = 0;
82 LogPrintf(
"Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%d\n", vDeploymentParams[0], vbparams.start_time, vbparams.timeout, vbparams.min_activation_height);
87 throw std::runtime_error(
strprintf(
"Invalid deployment (%s)", vDeploymentParams[0]));
114 throw std::runtime_error(
strprintf(
"%s: Unknown chain %s.", __func__, chain));
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
static std::unique_ptr< const CChainParams > globalChainParams
const CChainParams & Params()
Return the currently selected parameters.
void ReadSigNetArgs(const ArgsManager &args, CChainParams::SigNetOptions &options)
void ReadRegTestArgs(const ArgsManager &args, CChainParams::RegTestOptions &options)
void SelectBaseParams(const std::string &chain)
Sets the params returned by Params() to those for the given network.
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
static const std::string REGTEST
static const std::string TESTNET
static const std::string SIGNET
static const std::string MAIN
Chain name strings.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
static std::unique_ptr< const CChainParams > Main()
static std::unique_ptr< const CChainParams > RegTest(const RegTestOptions &options)
static std::unique_ptr< const CChainParams > TestNet()
static std::unique_ptr< const CChainParams > SigNet(const SigNetOptions &options)
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
std::optional< Consensus::BuriedDeployment > GetBuriedDeployment(const std::string_view name)
@ MAX_VERSION_BITS_DEPLOYMENTS
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
std::vector< std::string > SplitString(std::string_view str, char sep)
RegTestOptions holds configurations for creating a regtest CChainParams.
std::unordered_map< Consensus::DeploymentPos, VersionBitsParameters > version_bits_parameters
std::unordered_map< Consensus::BuriedDeployment, int > activation_heights
SigNetOptions holds configurations for creating a signet CChainParams.
std::optional< std::vector< uint8_t > > challenge
std::optional< std::vector< std::string > > seeds
VersionBitsParameters holds activation parameters.
bool ParseInt32(std::string_view str, int32_t *out)
Convert string to signed 32-bit integer with strict parse error feedback.
bool ParseInt64(std::string_view str, int64_t *out)
Convert string to signed 64-bit integer with strict parse error feedback.