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)};
56 const auto height{ToIntegral<int32_t>(value)};
57 if (!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));
69 for (
const std::string& strDeployment :
args.
GetArgs(
"-vbparams")) {
70 std::vector<std::string> vDeploymentParams =
SplitString(strDeployment,
':');
71 if (vDeploymentParams.size() < 3 || 4 < vDeploymentParams.size()) {
72 throw std::runtime_error(
"Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
75 const auto start_time{ToIntegral<int64_t>(vDeploymentParams[1])};
77 throw std::runtime_error(
strprintf(
"Invalid nStartTime (%s)", vDeploymentParams[1]));
79 vbparams.start_time = *start_time;
80 const auto timeout{ToIntegral<int64_t>(vDeploymentParams[2])};
82 throw std::runtime_error(
strprintf(
"Invalid nTimeout (%s)", vDeploymentParams[2]));
84 vbparams.timeout = *timeout;
85 if (vDeploymentParams.size() >= 4) {
86 const auto min_activation_height{ToIntegral<int64_t>(vDeploymentParams[3])};
87 if (!min_activation_height) {
88 throw std::runtime_error(
strprintf(
"Invalid min_activation_height (%s)", vDeploymentParams[3]));
90 vbparams.min_activation_height = *min_activation_height;
92 vbparams.min_activation_height = 0;
99 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);
104 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 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 std::array< VBDeploymentInfo, Consensus::MAX_VERSION_BITS_DEPLOYMENTS > VersionBitsDeploymentInfo
@ 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.