Skip to content

Commit

Permalink
Disable mainnet/testnet operation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ajtowns committed Jan 12, 2023
1 parent b3f866a commit 3707f27
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 98 deletions.
5 changes: 5 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
const ArgsManager& args = *Assert(node.args);
const CChainParams& chainparams = Params();

// Disallow mainnet/testnet operation
if (Params().NetworkIDString() == CBaseChainParams::MAIN || Params().NetworkIDString() == CBaseChainParams::TESTNET) {
return InitError(Untranslated(strprintf("Selected network '%s' is unsupported for this client, select -regtest or -signet instead.\n", Params().NetworkIDString())));
}

auto opt_max_upload = ParseByteUnits(args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET), ByteUnit::M);
if (!opt_max_upload) {
return InitError(strprintf(_("Unable to parse -maxuploadtarget: '%s'"), args.GetArg("-maxuploadtarget", "")));
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ int GuiMain(int argc, char* argv[])
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what()));
return EXIT_FAILURE;
}

#ifdef ENABLE_WALLET
// Parse URIs on command line
PaymentServer::ipcParseCommandLine(argc, argv);
Expand Down
10 changes: 5 additions & 5 deletions test/functional/feature_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def test_config_file_parser(self):
conf.write("wallet=foo\n")
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.')

main_conf_file_path = os.path.join(self.options.tmpdir, 'node0', 'bitcoin_main.conf')
util.write_config(main_conf_file_path, n=0, chain='', extra_config=f'includeconf={inc_conf_file_path}\n')
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
conf.write('acceptnonstdtxn=1\n')
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')
#main_conf_file_path = os.path.join(self.options.tmpdir, 'node0', 'bitcoin_main.conf')
#util.write_config(main_conf_file_path, n=0, chain='', extra_config=f'includeconf={inc_conf_file_path}\n')
#with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
# conf.write('acceptnonstdtxn=1\n')
#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')

with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
conf.write('nono\n')
Expand Down
88 changes: 0 additions & 88 deletions test/functional/p2p_dos_header_tree.py

This file was deleted.

1 change: 0 additions & 1 deletion test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@
'wallet_coinbase_category.py --descriptors',
'feature_filelock.py',
'feature_loadblock.py',
'p2p_dos_header_tree.py',
'p2p_add_connections.py',
'feature_bind_port_discover.py',
'p2p_unrequested_blocks.py',
Expand Down
8 changes: 4 additions & 4 deletions test/functional/wallet_crosschain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def skip_test_if_missing_module(self):
def setup_network(self):
self.add_nodes(self.num_nodes)

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

self.start_nodes()

Expand Down

0 comments on commit 3707f27

Please sign in to comment.