32 const auto signet_challenge =
args.
GetArgs(
"-signetchallenge");
33 if (signet_challenge.size() != 1) {
34 throw std::runtime_error(
"-signetchallenge cannot be multiple values.");
36 const auto val{TryParseHex<uint8_t>(signet_challenge[0])};
38 throw std::runtime_error(
strprintf(
"-signetchallenge must be hex, not '%s'.", signet_challenge[0]));
49 for (
const std::string& arg :
args.
GetArgs(
"-testactivationheight")) {
50 const auto found{arg.find(
'@')};
51 if (found == std::string::npos) {
52 throw std::runtime_error(
strprintf(
"Invalid format (%s) for -testactivationheight=name@height.", arg));
55 const auto value{arg.substr(found + 1)};
57 if (!
ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits<int>::max()) {
58 throw std::runtime_error(
strprintf(
"Invalid height value (%s) for -testactivationheight=name@height.", arg));
61 const auto deployment_name{arg.substr(0, found)};
65 throw std::runtime_error(
strprintf(
"Invalid name (%s) for -testactivationheight=name@height.", arg));
71 for (
const std::string& strDeployment :
args.
GetArgs(
"-vbparams")) {
72 std::vector<std::string> vDeploymentParams =
SplitString(strDeployment,
':');
73 if (vDeploymentParams.size() < 3 || 4 < vDeploymentParams.size()) {
74 throw std::runtime_error(
"Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
77 if (!
ParseInt64(vDeploymentParams[1], &vbparams.start_time)) {
78 throw std::runtime_error(
strprintf(
"Invalid nStartTime (%s)", vDeploymentParams[1]));
80 if (!
ParseInt64(vDeploymentParams[2], &vbparams.timeout)) {
81 throw std::runtime_error(
strprintf(
"Invalid nTimeout (%s)", vDeploymentParams[2]));
83 if (vDeploymentParams.size() >= 4) {
84 if (!
ParseInt32(vDeploymentParams[3], &vbparams.min_activation_height)) {
85 throw std::runtime_error(
strprintf(
"Invalid min_activation_height (%s)", vDeploymentParams[3]));
88 vbparams.min_activation_height = 0;
95 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);
100 throw std::runtime_error(
strprintf(
"Invalid deployment (%s)", vDeploymentParams[0]));
bool HasTestOption(const ArgsManager &args, const std::string &test_option)
Checks if a particular test option is present in -test command-line arg options.
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const ChainType chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
static std::unique_ptr< const CChainParams > globalChainParams
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain type.
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 ChainType chain)
Sets the params returned by Params() to those for the given chain.
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.
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 > TestNet4()
static std::unique_ptr< const CChainParams > SigNet(const SigNetOptions &options)
std::optional< Consensus::BuriedDeployment > GetBuriedDeployment(const std::string_view name)
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
@ MAX_VERSION_BITS_DEPLOYMENTS
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.