+ if (!mapMultiArgs["-nuparams"].empty()) {
+ // Allow overriding network upgrade parameters for testing
+ if (Params().NetworkIDString() != "regtest") {
+ return InitError("Network upgrade parameters may only be overridden on regtest.");
+ }
+ const vector<string>& deployments = mapMultiArgs["-nuparams"];
+ for (auto i : deployments) {
+ std::vector<std::string> vDeploymentParams;
+ boost::split(vDeploymentParams, i, boost::is_any_of(":"));
+ if (vDeploymentParams.size() != 2) {
+ return InitError("Network upgrade parameters malformed, expecting hexBranchId:activationHeight");
+ }
+ int nActivationHeight;
+ if (!ParseInt32(vDeploymentParams[1], &nActivationHeight)) {
+ return InitError(strprintf("Invalid nActivationHeight (%s)", vDeploymentParams[1]));
+ }
+ bool found = false;
+ // Exclude Sprout from upgrades
+ for (auto i = Consensus::BASE_SPROUT + 1; i < Consensus::MAX_NETWORK_UPGRADES; ++i)
+ {
+ if (vDeploymentParams[0].compare(HexInt(NetworkUpgradeInfo[i].nBranchId)) == 0) {
+ UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex(i), nActivationHeight);
+ found = true;
+ LogPrintf("Setting network upgrade activation parameters for %s to height=%d\n", vDeploymentParams[0], nActivationHeight);
+ break;
+ }
+ }
+ if (!found) {
+ return InitError(strprintf("Invalid network upgrade (%s)", vDeploymentParams[0]));
+ }
+ }
+ }