From a933a60b1a9332e03047c7b226b654cd05a1fe66 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 17 Apr 2024 13:58:27 +0700 Subject: [PATCH] feat: new command line argument -bip147height for bitcoin#21373 This command line argument is substitute for -segwitheight so far as dash does not have a segwit feature --- src/chainparams.cpp | 19 +++++++++++++++++++ src/chainparamsbase.cpp | 1 + 2 files changed, 20 insertions(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9f98fd16c6..29c0e20e03 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -861,6 +861,7 @@ public: UpdateActivationParametersFromArgs(args); UpdateDIP3ParametersFromArgs(args); UpdateDIP8ParametersFromArgs(args); + UpdateBIP147ParametersFromArgs(args); UpdateBudgetParametersFromArgs(args); genesis = CreateGenesisBlock(1417713337, 1096447, 0x207fffff, 1, 50 * COIN); @@ -986,6 +987,12 @@ public: } void UpdateDIP8ParametersFromArgs(const ArgsManager& args); + void UpdateBIP147Parameters(int nActivationHeight) + { + consensus.BIP147Height = nActivationHeight; + } + void UpdateBIP147ParametersFromArgs(const ArgsManager& args); + /** * Allows modifying the budget regtest parameters. */ @@ -1118,6 +1125,18 @@ void CRegTestParams::UpdateDIP8ParametersFromArgs(const ArgsManager& args) UpdateDIP8Parameters(nDIP8ActivationHeight); } +void CRegTestParams::UpdateBIP147ParametersFromArgs(const ArgsManager& args) +{ + if (!args.IsArgSet("-bip147height")) return; + int nBIP147Height; + const std::string strParams = args.GetArg("-bip147height", ""); + if (!ParseInt32(strParams, &nBIP147Height)) { + throw std::runtime_error(strprintf("Invalid activation height (%s)", strParams)); + } + LogPrintf("Setting BIP147 parameters to activation=%lld\n", nBIP147Height); + UpdateBIP147Parameters(nBIP147Height); +} + void CRegTestParams::UpdateBudgetParametersFromArgs(const ArgsManager& args) { if (!args.IsArgSet("-budgetparams")) return; diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index af4310de08..0ed763e735 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -21,6 +21,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman) argsman.AddArg("-devnet=", "Use devnet chain with provided name", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-dip3params=:", "Override DIP3 activation and enforcement heights (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-dip8params=", "Override DIP8 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); + argsman.AddArg("-bip147height=", "Override BIP147 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-highsubsidyblocks=", "The number of blocks with a higher than normal subsidy to mine at the start of a chain. Block after that height will have fixed subsidy base. (default: 0, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-highsubsidyfactor=", "The factor to multiply the normal block subsidy by while in the highsubsidyblocks window of a chain (default: 1, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqchainlocks=", "Override the default LLMQ type used for ChainLocks. Allows using ChainLocks with smaller LLMQs. (default: llmq_devnet, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);