Skip to content

Commit 71283f7

Browse files
committed
init: Inform user of upcoming RDTS softfork and lack of enforcement by this software
1 parent 2e43706 commit 71283f7

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

src/init.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,54 @@ bool UserProtocolRulesCheck()
13391339
return InitError(strprintf(_("Unknown rule specified in -%s: %s"), CONSENSUSRULES_CONFIG_NAME, rules_requested.front()));
13401340
}
13411341

1342+
bool UserProtocolRulesConsent()
1343+
{
1344+
static const std::string CONSENSUSRULES_MISSING{"rdts"};
1345+
bool require_rdts{false};
1346+
for (const auto& rulesok : gArgs.GetArgs(CONSENSUSRULES_CONFIG_NAME)) {
1347+
if (rulesok == CONSENSUSRULES_MISSING) {
1348+
LogPrintf("User already consented to '%s' consensus rules\n", CONSENSUSRULES_MISSING);
1349+
require_rdts = true;
1350+
break;
1351+
}
1352+
}
1353+
1354+
bilingual_str msg = strprintf(_(
1355+
"Bitcoin protocol change proposed\n"
1356+
"\n"
1357+
"A one-year \"reduced data\" protocol change to the Bitcoin rules, beginning no later than September, has been proposed. "
1358+
"This upgrade fixes an existential threat to the Bitcoin network.\n"
1359+
"\n"
1360+
"Protocol changes require user consent to be effective, and if enforced inconsistently within the community may compromise your security or others'!\n"
1361+
"\n"
1362+
"If you do not know what you are doing, you can learn more at %s.\n"
1363+
"\n"
1364+
"Note that to reject this softfork, you must implement your own rejection fork.\n"
1365+
"(You must make a decision either way - old versions are insecure in all scenarios.)\n"
1366+
"\n"
1367+
"This release of %s does NOT include the protocol change, and will be insecure when it activates. "
1368+
"You can download the latest version from %s."
1369+
), "https://bitcoinknots.org/learn/2026-rdts",
1370+
CLIENT_NAME,
1371+
CLIENT_URL);
1372+
if (require_rdts) {
1373+
const bilingual_str msg_config_suffix = strprintf(_(
1374+
"To run this version, you must remove from your config files: %s"
1375+
), CONSENSUSRULES_CONFIG_NAME + "=" + CONSENSUSRULES_MISSING);
1376+
msg += Untranslated("\n\n") + msg_config_suffix;
1377+
}
1378+
1379+
const bool consent = uiInterface.ThreadSafeQuestion(
1380+
_("Caution:") + Untranslated(" ") + msg,
1381+
msg.original
1382+
, "Caution",
1383+
require_rdts
1384+
? (CClientUIInterface::ICON_WARNING | CClientUIInterface::BTN_ABORT | CClientUIInterface::MODAL)
1385+
: (CClientUIInterface::MSG_WARNING | CClientUIInterface::BTN_ABORT | CClientUIInterface::DEFAULT_TRUE));
1386+
1387+
return consent;
1388+
}
1389+
13421390
bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
13431391
{
13441392
const ArgsManager& args = *Assert(node.args);
@@ -1404,6 +1452,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14041452
g_wallet_init_interface.Construct(node);
14051453
uiInterface.InitWallet();
14061454

1455+
if (!(chainparams.IsTestChain() || UserProtocolRulesConsent())) {
1456+
return false;
1457+
}
1458+
14071459
if (!UserProtocolRulesCheck()) {
14081460
return false;
14091461
}

test/functional/feature_config_args.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ def test_acceptstalefeeestimates_arg_support(self):
464464
conf_file = self.nodes[0].datadir_path / "bitcoin.conf"
465465
for chain, chain_name in {("main", ""), ("test", "testnet3"), ("signet", "signet"), ("testnet4", "testnet4")}:
466466
util.write_config(conf_file, n=0, chain=chain_name, extra_config='acceptstalefeeestimates=1\n')
467+
self.nodes[0].expected_stderr_prefix = self.MAINNET_NORMAL_STDERR if (chain_name == '') else ''
467468
self.nodes[0].assert_start_raises_init_error(expected_msg=f'Error: acceptstalefeeestimates is not supported on {chain} chain.')
468469
util.write_config(conf_file, n=0, chain="regtest") # Reset to regtest
469470

test/functional/mining_mainnet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def set_test_params(self):
4444
self.num_nodes = 1
4545
self.setup_clean_chain = True
4646
self.chain = "" # main
47+
self.MAINNET_NORMAL_STDERR = '' # because we truncate the message away
4748

4849
def add_options(self, parser):
4950
parser.add_argument(

test/functional/test_framework/test_framework.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,19 @@ def parse_args(self, test_file):
243243

244244
PortSeed.n = self.options.port_seed
245245

246+
self.MAINNET_NORMAL_STDERR = f'''Caution: Bitcoin protocol change proposed
247+
248+
A one-year "reduced data" protocol change to the Bitcoin rules, beginning no later than September, has been proposed. This upgrade fixes an existential threat to the Bitcoin network.
249+
250+
Protocol changes require user consent to be effective, and if enforced inconsistently within the community may compromise your security or others'!
251+
252+
If you do not know what you are doing, you can learn more at https://bitcoinknots.org/learn/2026-rdts.
253+
254+
Note that to reject this softfork, you must implement your own rejection fork.
255+
(You must make a decision either way - old versions are insecure in all scenarios.)
256+
257+
This release of {self.config['environment']['CLIENT_NAME']} does NOT include the protocol change, and will be insecure when it activates. You can download the latest version from {self.config['environment']['CLIENT_URL']}.'''
258+
246259
def set_binary_paths(self):
247260
"""Update self.options with the paths of all binaries from environment variables or their default values"""
248261

0 commit comments

Comments
 (0)