chainparams: add overloads for RegTest and SigNet with no options
What changed, and why it matters
This commit is a small internal code cleanup for Bitcoin Core. It adds shortcut versions of two functions used only for test networks (RegTest and SigNet) so callers don't have to pass an empty options object. There is no user-facing change and no security relevance.
No action required. This is a non-functional refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds parameterless overloads CChainParams::RegTest() and CChainParams::SigNet() that internally create default RegTestOptions/SigNetOptions and forward to the existing overloads. It then updates two call sites in bitcoinkernel.cpp and chainparams.cpp to use the new overloads instead of explicitly passing {}. The behavior is identical; it is purely a readability/consistency refactor.
Changed components
src/kernel/chainparams.hsrc/kernel/chainparams.cppsrc/kernel/bitcoinkernel.cppInspect captured patch +6 / −4
diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp
index 0a315ff3..9eef0b7f 100644
--- a/src/kernel/bitcoinkernel.cpp
+++ b/src/kernel/bitcoinkernel.cpp
@@ -816,10 +816,10 @@ btck_ChainParameters* btck_chain_parameters_create(const btck_ChainType chain_ty
return btck_ChainParameters::ref(const_cast<CChainParams*>(CChainParams::TestNet4().release()));
}
case btck_ChainType_SIGNET: {
- return btck_ChainParameters::ref(const_cast<CChainParams*>(CChainParams::SigNet({}).release()));
+ return btck_ChainParameters::ref(const_cast<CChainParams*>(CChainParams::SigNet().release()));
}
case btck_ChainType_REGTEST: {
- return btck_ChainParameters::ref(const_cast<CChainParams*>(CChainParams::RegTest({}).release()));
+ return btck_ChainParameters::ref(const_cast<CChainParams*>(CChainParams::RegTest().release()));
}
}
assert(false);
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index 93bfe335..8b2e66a2 100644
--- a/src/kernel/chainparams.cpp
+++ b/src/kernel/chainparams.cpp
@@ -703,8 +703,8 @@ std::optional<ChainType> GetNetworkForMagic(const MessageStartChars& message)
const auto mainnet_msg = CChainParams::Main()->MessageStart();
const auto testnet_msg = CChainParams::TestNet()->MessageStart();
const auto testnet4_msg = CChainParams::TestNet4()->MessageStart();
- const auto regtest_msg = CChainParams::RegTest({})->MessageStart();
- const auto signet_msg = CChainParams::SigNet({})->MessageStart();
+ const auto regtest_msg = CChainParams::RegTest()->MessageStart();
+ const auto signet_msg = CChainParams::SigNet()->MessageStart();
if (std::ranges::equal(message, mainnet_msg)) {
return ChainType::MAIN;
diff --git a/src/kernel/chainparams.h b/src/kernel/chainparams.h
index b78c5635..2c85b8e8 100644
--- a/src/kernel/chainparams.h
+++ b/src/kernel/chainparams.h
@@ -168,7 +168,9 @@ public:
};
static std::unique_ptr<const CChainParams> RegTest(const RegTestOptions& options);
+ static std::unique_ptr<const CChainParams> RegTest() { const RegTestOptions opts{}; return RegTest(opts); }
static std::unique_ptr<const CChainParams> SigNet(const SigNetOptions& options);
+ static std::unique_ptr<const CChainParams> SigNet() { const SigNetOptions opts{}; return SigNet(opts); }
static std::unique_ptr<const CChainParams> Main(const MainNetOptions& options);
static std::unique_ptr<const CChainParams> Main() { const MainNetOptions opts{}; return Main(opts); }
static std::unique_ptr<const CChainParams> TestNet(const TestNetOptions& options);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.