Skip to content

Commit 3707f27

Browse files
committed
Disable mainnet/testnet operation
To avoid the risk of bugs in new consensus code causing potential chain splits or loss of funds, we disable use of this branch on mainnet or testnet. Use with either regtest or signet remains supported.
1 parent b3f866a commit 3707f27

File tree

6 files changed

+15
-98
lines changed

6 files changed

+15
-98
lines changed

src/init.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
10951095
const ArgsManager& args = *Assert(node.args);
10961096
const CChainParams& chainparams = Params();
10971097

1098+
// Disallow mainnet/testnet operation
1099+
if (Params().NetworkIDString() == CBaseChainParams::MAIN || Params().NetworkIDString() == CBaseChainParams::TESTNET) {
1100+
return InitError(Untranslated(strprintf("Selected network '%s' is unsupported for this client, select -regtest or -signet instead.\n", Params().NetworkIDString())));
1101+
}
1102+
10981103
auto opt_max_upload = ParseByteUnits(args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET), ByteUnit::M);
10991104
if (!opt_max_upload) {
11001105
return InitError(strprintf(_("Unable to parse -maxuploadtarget: '%s'"), args.GetArg("-maxuploadtarget", "")));

src/qt/bitcoin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ int GuiMain(int argc, char* argv[])
621621
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what()));
622622
return EXIT_FAILURE;
623623
}
624+
624625
#ifdef ENABLE_WALLET
625626
// Parse URIs on command line
626627
PaymentServer::ipcParseCommandLine(argc, argv);

test/functional/feature_config_args.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def test_config_file_parser(self):
4545
conf.write("wallet=foo\n")
4646
self.nodes[0].assert_start_raises_init_error(expected_msg=f'Error: Config setting for -wallet only applied on {self.chain} network when in [{self.chain}] section.')
4747

48-
main_conf_file_path = os.path.join(self.options.tmpdir, 'node0', 'bitcoin_main.conf')
49-
util.write_config(main_conf_file_path, n=0, chain='', extra_config=f'includeconf={inc_conf_file_path}\n')
50-
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
51-
conf.write('acceptnonstdtxn=1\n')
52-
self.nodes[0].assert_start_raises_init_error(extra_args=[f"-conf={main_conf_file_path}"], expected_msg='Error: acceptnonstdtxn is not currently supported for main chain')
48+
#main_conf_file_path = os.path.join(self.options.tmpdir, 'node0', 'bitcoin_main.conf')
49+
#util.write_config(main_conf_file_path, n=0, chain='', extra_config=f'includeconf={inc_conf_file_path}\n')
50+
#with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
51+
# conf.write('acceptnonstdtxn=1\n')
52+
#self.nodes[0].assert_start_raises_init_error(extra_args=[f"-conf={main_conf_file_path}"], expected_msg='Error: acceptnonstdtxn is not currently supported for main chain')
5353

5454
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
5555
conf.write('nono\n')

test/functional/p2p_dos_header_tree.py

Lines changed: 0 additions & 88 deletions
This file was deleted.

test/functional/test_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@
301301
'wallet_coinbase_category.py --descriptors',
302302
'feature_filelock.py',
303303
'feature_loadblock.py',
304-
'p2p_dos_header_tree.py',
305304
'p2p_add_connections.py',
306305
'feature_bind_port_discover.py',
307306
'p2p_unrequested_blocks.py',

test/functional/wallet_crosschain.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ def skip_test_if_missing_module(self):
1919
def setup_network(self):
2020
self.add_nodes(self.num_nodes)
2121

22-
# Switch node 1 to testnet before starting it.
23-
self.nodes[1].chain = 'testnet3'
24-
self.nodes[1].extra_args = ['-maxconnections=0'] # disable testnet sync
22+
# Switch node 1 to signet before starting it.
23+
self.nodes[1].chain = 'signet'
24+
self.nodes[1].extra_args = ['-maxconnections=0'] # disable signet sync
2525
with open(self.nodes[1].bitcoinconf, 'r', encoding='utf8') as conf:
2626
conf_data = conf.read()
2727
with open (self.nodes[1].bitcoinconf, 'w', encoding='utf8') as conf:
28-
conf.write(conf_data.replace('regtest=', 'testnet=').replace('[regtest]', '[test]'))
28+
conf.write(conf_data.replace('regtest=', 'signet=').replace('[regtest]', '[signet]'))
2929

3030
self.start_nodes()
3131

0 commit comments

Comments
 (0)