Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
2e73739
coinselection: Track BnB iteration count in result
murchandamus Mar 26, 2025
3ca0f36
coinselection: rewrite BnB in CoinGrinder-style
murchandamus Mar 26, 2025
7ecea1d
coinselection: Track whether BnB completed
murchandamus Mar 27, 2025
fa226ab
coinselection: BnB skip exploring high waste
murchandamus Mar 27, 2025
ba1807b
coinselection: Track effective_value lookahead
murchandamus Mar 27, 2025
5204291
opt: Skip evaluation of equivalent input sets
murchandamus Mar 27, 2025
7249b37
opt: Skip UTXOs with worse waste, same eff_value
murchandamus Mar 27, 2025
df7ed5f
chainparams: encapsulate deployment configuration logic
darosior Sep 29, 2025
4995c00
chainparams: make deployment configuration available on all test netw…
darosior Sep 29, 2025
801e3bf
chainparams: add overloads for RegTest and SigNet with no options
darosior May 25, 2026
f802edf
versionbits: Limit live activation params and activation warnings per…
ajtowns Mar 10, 2026
1d52405
qa: test we don't warn for ignored unknown version bits deployments
darosior Mar 9, 2026
94e3ac0
doc: release notes and bips doc update for #34779
darosior May 20, 2026
107d417
versionbits: update VersionBitsCache doc comment to match current beh…
darosior May 20, 2026
5bd990a
Merge bitcoin/bitcoin#34779: BIP 323: reserve version bits 5-28 as ex…
achow101 Jun 3, 2026
082bb1a
Merge bitcoin/bitcoin#35335: Make deployment configuration available …
achow101 Jun 3, 2026
a5050dd
Merge bitcoin/bitcoin#32150: coinselection: Optimize BnB exploration
achow101 Jun 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/bips.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ BIPs that are implemented by Bitcoin Core:
* [`BIP 173`](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki): Bech32 addresses for native Segregated Witness outputs are supported as of **v0.16.0** ([PR 11167](https://github.com/bitcoin/bitcoin/pull/11167)). Bech32 addresses are generated by default as of **v0.20.0** ([PR 16884](https://github.com/bitcoin/bitcoin/pull/16884)).
* [`BIP 174`](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki): RPCs to operate on Partially Signed Bitcoin Transactions (PSBT) are present as of **v0.17.0** ([PR 13557](https://github.com/bitcoin/bitcoin/pull/13557)).
* [`BIP 176`](https://github.com/bitcoin/bips/blob/master/bip-0176.mediawiki): Bits Denomination [QT only] is supported as of **v0.16.0** ([PR 12035](https://github.com/bitcoin/bitcoin/pull/12035)).
* [`BIP 323`](https://github.com/bitcoin/bips/blob/master/bip-0323.mediawiki): BIP 9 bits 5 to 28 (inclusive) are ignored for soft-fork signalling and unknown soft fork warnings as of **v32.0**.
* [`BIP 324`](https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki): The v2 transport protocol specified by BIP324 and the associated `NODE_P2P_V2` service bit are supported as of **v26.0**, but off by default ([PR 28331](https://github.com/bitcoin/bitcoin/pull/28331)). On by default as of **v27.0** ([PR 29347](https://github.com/bitcoin/bitcoin/pull/29347)).
* [`BIP 325`](https://github.com/bitcoin/bips/blob/master/bip-0325.mediawiki): Signet test network is supported as of **v0.21.0** ([PR 18267](https://github.com/bitcoin/bitcoin/pull/18267)).
* [`BIP 327`](https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki): Key aggregation via `musig()` descriptors is supported as of **v30.0** ([PR 31244](https://github.com/bitcoin/bitcoin/pull/31244)). Signing is supported as of **v31.0** ([PR 29675](https://github.com/bitcoin/bitcoin/pull/29675))
Expand Down
5 changes: 5 additions & 0 deletions doc/release-notes-34779.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Logging
-------

- BIP 9 bits 5 to 28 inclusive are now ignored for soft fork signaling, as per BIP 323. We won't
warn about unknown deployments when receiving blocks that set any of those bits in their version.
81 changes: 53 additions & 28 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,8 @@

using util::SplitString;

void ReadSigNetArgs(const ArgsManager& args, CChainParams::SigNetOptions& options)
{
if (!args.GetArgs("-signetseednode").empty()) {
options.seeds.emplace(args.GetArgs("-signetseednode"));
}
if (!args.GetArgs("-signetchallenge").empty()) {
const auto signet_challenge = args.GetArgs("-signetchallenge");
if (signet_challenge.size() != 1) {
throw std::runtime_error("-signetchallenge cannot be multiple values.");
}
const auto val{TryParseHex<uint8_t>(signet_challenge[0])};
if (!val) {
throw std::runtime_error(strprintf("-signetchallenge must be hex, not '%s'.", signet_challenge[0]));
}
options.challenge.emplace(*val);
}
}

void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options)
static void HandleDeploymentArgs(const ArgsManager& args, CChainParams::DeploymentOptions& options)
{
if (auto value = args.GetBoolArg("-fastprune")) options.fastprune = *value;
if (HasTestOption(args, "bip94")) options.enforce_bip94 = true;

for (const std::string& arg : args.GetArgs("-testactivationheight")) {
const auto found{arg.find('@')};
if (found == std::string::npos) {
Expand Down Expand Up @@ -107,6 +86,43 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
}
}

void ReadMainNetArgs(const ArgsManager& args, CChainParams::MainNetOptions& options)
{
HandleDeploymentArgs(args, options.dep_opts);
}

void ReadTestNetArgs(const ArgsManager& args, CChainParams::TestNetOptions& options)
{
HandleDeploymentArgs(args, options.dep_opts);
}

void ReadSigNetArgs(const ArgsManager& args, CChainParams::SigNetOptions& options)
{
if (!args.GetArgs("-signetseednode").empty()) {
options.seeds.emplace(args.GetArgs("-signetseednode"));
}
if (!args.GetArgs("-signetchallenge").empty()) {
const auto signet_challenge = args.GetArgs("-signetchallenge");
if (signet_challenge.size() != 1) {
throw std::runtime_error("-signetchallenge cannot be multiple values.");
}
const auto val{TryParseHex<uint8_t>(signet_challenge[0])};
if (!val) {
throw std::runtime_error(strprintf("-signetchallenge must be hex, not '%s'.", signet_challenge[0]));
}
options.challenge.emplace(*val);
}
HandleDeploymentArgs(args, options.dep_opts);
}

void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options)
{
if (auto value = args.GetBoolArg("-fastprune")) options.fastprune = *value;
if (HasTestOption(args, "bip94")) options.enforce_bip94 = true;

HandleDeploymentArgs(args, options.dep_opts);
}

static std::unique_ptr<const CChainParams> globalChainParams;

const CChainParams &Params() {
Expand All @@ -117,12 +133,21 @@ const CChainParams &Params() {
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const ChainType chain)
{
switch (chain) {
case ChainType::MAIN:
return CChainParams::Main();
case ChainType::TESTNET:
return CChainParams::TestNet();
case ChainType::TESTNET4:
return CChainParams::TestNet4();
case ChainType::MAIN: {
auto opts = CChainParams::MainNetOptions{};
ReadMainNetArgs(args, opts);
return CChainParams::Main(opts);
}
case ChainType::TESTNET: {
auto opts = CChainParams::TestNetOptions{};
ReadTestNetArgs(args, opts);
return CChainParams::TestNet(opts);
}
case ChainType::TESTNET4: {
auto opts = CChainParams::TestNetOptions{};
ReadTestNetArgs(args, opts);
return CChainParams::TestNet4(opts);
}
case ChainType::SIGNET: {
auto opts = CChainParams::SigNetOptions{};
ReadSigNetArgs(args, opts);
Expand Down
4 changes: 2 additions & 2 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: " LIST_CHAIN_NAMES, ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
"This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (test-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-testnet", "Use the testnet3 chain. Equivalent to -chain=test. Support for testnet3 is deprecated and will be removed in an upcoming release. Consider moving to testnet4 now by using -testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-testnet4", "Use the testnet4 chain. Equivalent to -chain=testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (test-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signetchallenge", "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signetseednode", "Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s))", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
Expand Down
10 changes: 10 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,16 @@ bool AppInitParameterInteraction(const ArgsManager& args)
}
}

// Prevent setting deployment parameters on mainnet.
if (chainparams.GetChainType() == ChainType::MAIN) {
if (args.IsArgSet("-testactivationheight")) {
return InitError(_("The -testactivationheight option may not be used on mainnet."));
}
if (args.IsArgSet("-vbparams")) {
return InitError(_("The -vbparams option may not be used on mainnet."));
}
}

// Also report errors from parsing before daemonization
{
kernel::Notifications notifications{};
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/bitcoinkernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,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);
Expand Down
85 changes: 49 additions & 36 deletions src/kernel/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,41 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}

void CChainParams::ApplyDeploymentOptions(const DeploymentOptions& opts)
{
for (const auto& [dep, height] : opts.activation_heights) {
switch (dep) {
case Consensus::BuriedDeployment::DEPLOYMENT_SEGWIT:
consensus.SegwitHeight = int{height};
break;
case Consensus::BuriedDeployment::DEPLOYMENT_HEIGHTINCB:
consensus.BIP34Height = int{height};
break;
case Consensus::BuriedDeployment::DEPLOYMENT_DERSIG:
consensus.BIP66Height = int{height};
break;
case Consensus::BuriedDeployment::DEPLOYMENT_CLTV:
consensus.BIP65Height = int{height};
break;
case Consensus::BuriedDeployment::DEPLOYMENT_CSV:
consensus.CSVHeight = int{height};
break;
}
}

for (const auto& [deployment_pos, version_bits_params] : opts.version_bits_parameters) {
consensus.vDeployments[deployment_pos].nStartTime = version_bits_params.start_time;
consensus.vDeployments[deployment_pos].nTimeout = version_bits_params.timeout;
consensus.vDeployments[deployment_pos].min_activation_height = version_bits_params.min_activation_height;
}
}

/**
* Main network on which people trade goods and services.
*/
class CMainParams : public CChainParams {
public:
CMainParams() {
CMainParams(const MainNetOptions& opts) {
m_chain_type = ChainType::MAIN;
consensus.signet_blocks = false;
consensus.signet_challenge.clear();
Expand Down Expand Up @@ -107,6 +136,8 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1815; // 90%
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;

ApplyDeploymentOptions(opts.dep_opts);

consensus.nMinimumChainWork = uint256{"0000000000000000000000000000000000000001128750f82f4c366153a3a030"};
consensus.defaultAssumeValid = uint256{"00000000000000000000ccebd6d74d9194d8dcdc1d177c478e094bfad51ba5ac"}; // 938343

Expand Down Expand Up @@ -203,7 +234,7 @@ class CMainParams : public CChainParams {
*/
class CTestNetParams : public CChainParams {
public:
CTestNetParams() {
CTestNetParams(const TestNetOptions& opts) {
m_chain_type = ChainType::TESTNET;
consensus.signet_blocks = false;
consensus.signet_challenge.clear();
Expand All @@ -230,6 +261,8 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1512; // 75%
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;

ApplyDeploymentOptions(opts.dep_opts);

consensus.nMinimumChainWork = uint256{"0000000000000000000000000000000000000000000017dde1c649f3708d14b6"};
consensus.defaultAssumeValid = uint256{"000000007a61e4230b28ac5cb6b5e5a0130de37ac1faf2f8987d2fa6505b67f4"}; // 4842348

Expand Down Expand Up @@ -304,7 +337,7 @@ class CTestNetParams : public CChainParams {
*/
class CTestNet4Params : public CChainParams {
public:
CTestNet4Params() {
CTestNet4Params(const TestNetOptions& opts) {
m_chain_type = ChainType::TESTNET4;
consensus.signet_blocks = false;
consensus.signet_challenge.clear();
Expand All @@ -330,6 +363,8 @@ class CTestNet4Params : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1512; // 75%
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;

ApplyDeploymentOptions(opts.dep_opts);

consensus.nMinimumChainWork = uint256{"0000000000000000000000000000000000000000000009a0fe15d0177d086304"};
consensus.defaultAssumeValid = uint256{"0000000002368b1e4ee27e2e85676ae6f9f9e69579b29093e9a82c170bf7cf8a"}; // 123613

Expand Down Expand Up @@ -473,6 +508,8 @@ class SigNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1815; // 90%
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;

ApplyDeploymentOptions(options.dep_opts);

// message start is defined as the first 4 bytes of the sha256d of the block script
HashWriter h{};
h << consensus.signet_challenge;
Expand Down Expand Up @@ -567,31 +604,7 @@ class CRegTestParams : public CChainParams
m_assumed_blockchain_size = 0;
m_assumed_chain_state_size = 0;

for (const auto& [dep, height] : opts.activation_heights) {
switch (dep) {
case Consensus::BuriedDeployment::DEPLOYMENT_SEGWIT:
consensus.SegwitHeight = int{height};
break;
case Consensus::BuriedDeployment::DEPLOYMENT_HEIGHTINCB:
consensus.BIP34Height = int{height};
break;
case Consensus::BuriedDeployment::DEPLOYMENT_DERSIG:
consensus.BIP66Height = int{height};
break;
case Consensus::BuriedDeployment::DEPLOYMENT_CLTV:
consensus.BIP65Height = int{height};
break;
case Consensus::BuriedDeployment::DEPLOYMENT_CSV:
consensus.CSVHeight = int{height};
break;
}
}

for (const auto& [deployment_pos, version_bits_params] : opts.version_bits_parameters) {
consensus.vDeployments[deployment_pos].nStartTime = version_bits_params.start_time;
consensus.vDeployments[deployment_pos].nTimeout = version_bits_params.timeout;
consensus.vDeployments[deployment_pos].min_activation_height = version_bits_params.min_activation_height;
}
ApplyDeploymentOptions(opts.dep_opts);

genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
Expand Down Expand Up @@ -660,19 +673,19 @@ std::unique_ptr<const CChainParams> CChainParams::RegTest(const RegTestOptions&
return std::make_unique<const CRegTestParams>(options);
}

std::unique_ptr<const CChainParams> CChainParams::Main()
std::unique_ptr<const CChainParams> CChainParams::Main(const MainNetOptions& options)
{
return std::make_unique<const CMainParams>();
return std::make_unique<const CMainParams>(options);
}

std::unique_ptr<const CChainParams> CChainParams::TestNet()
std::unique_ptr<const CChainParams> CChainParams::TestNet(const TestNetOptions& options)
{
return std::make_unique<const CTestNetParams>();
return std::make_unique<const CTestNetParams>(options);
}

std::unique_ptr<const CChainParams> CChainParams::TestNet4()
std::unique_ptr<const CChainParams> CChainParams::TestNet4(const TestNetOptions& options)
{
return std::make_unique<const CTestNet4Params>();
return std::make_unique<const CTestNet4Params>(options);
}

std::vector<int> CChainParams::GetAvailableSnapshotHeights() const
Expand All @@ -691,8 +704,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;
Expand Down
Loading
Loading