Skip to content

Commit 3dd2762

Browse files
committed
Merge bitcoin-core/gui#690: Catch invalid networks combination crash
f4a11d7 gui: bugfix, catch invalid networks combination crash (furszy) Pull request description: The app currently crashes if a network is set inside bitcoin.conf and another one is provided as param. The reason is an uncaught runtime_error. ACKs for top commit: jarolrod: tACK f4a11d7 johnny9: tACK f4a11d7 john-moffett: ACK f4a11d7 pablomartin4btc: Tested ACK f4a11d7. hebasto: ACK f4a11d7, tested on Ubuntu 22.04 (Qt 5.15.3). Tree-SHA512: fc5e26ae0a361e37d53d904cc122d07f064f261b309629c6386cb046ab1b3d2c805cbfe0db8ed3e934af52c6cf0ebb0bef9df9117b4330d9b0ea40c76f9270f9
2 parents 0c2a128 + f4a11d7 commit 3dd2762

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/qt/bitcoin.cpp

+16-15
Original file line numberDiff line numberDiff line change
@@ -592,29 +592,30 @@ int GuiMain(int argc, char* argv[])
592592
// Gracefully exit if the user cancels
593593
if (!Intro::showIfNeeded(did_show_intro, prune_MiB)) return EXIT_SUCCESS;
594594

595-
/// 6. Determine availability of data directory and parse bitcoin.conf
596-
/// - Do not call gArgs.GetDataDirNet() before this step finishes
595+
/// 6a. Determine availability of data directory
597596
if (!CheckDataDirOption()) {
598597
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
599598
QMessageBox::critical(nullptr, PACKAGE_NAME,
600599
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
601600
return EXIT_FAILURE;
602601
}
603-
if (!gArgs.ReadConfigFiles(error, true)) {
604-
InitError(strprintf(Untranslated("Error reading configuration file: %s\n"), error));
605-
QMessageBox::critical(nullptr, PACKAGE_NAME,
606-
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
607-
return EXIT_FAILURE;
608-
}
602+
try {
603+
/// 6b. Parse bitcoin.conf
604+
/// - Do not call gArgs.GetDataDirNet() before this step finishes
605+
if (!gArgs.ReadConfigFiles(error, true)) {
606+
InitError(strprintf(Untranslated("Error reading configuration file: %s\n"), error));
607+
QMessageBox::critical(nullptr, PACKAGE_NAME,
608+
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
609+
return EXIT_FAILURE;
610+
}
609611

610-
/// 7. Determine network (and switch to network specific options)
611-
// - Do not call Params() before this step
612-
// - Do this after parsing the configuration file, as the network can be switched there
613-
// - QSettings() will use the new application name after this, resulting in network-specific settings
614-
// - Needs to be done before createOptionsModel
612+
/// 7. Determine network (and switch to network specific options)
613+
// - Do not call Params() before this step
614+
// - Do this after parsing the configuration file, as the network can be switched there
615+
// - QSettings() will use the new application name after this, resulting in network-specific settings
616+
// - Needs to be done before createOptionsModel
615617

616-
// Check for chain settings (Params() calls are only valid after this clause)
617-
try {
618+
// Check for chain settings (Params() calls are only valid after this clause)
618619
SelectParams(gArgs.GetChainName());
619620
} catch(std::exception &e) {
620621
InitError(Untranslated(strprintf("%s\n", e.what())));

0 commit comments

Comments
 (0)