Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin); | Q_IMPORT_PLUGIN(QXcbIntegrationPlugin); | ||||
#elif defined(QT_QPA_PLATFORM_WINDOWS) | #elif defined(QT_QPA_PLATFORM_WINDOWS) | ||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); | Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); | ||||
#elif defined(QT_QPA_PLATFORM_COCOA) | #elif defined(QT_QPA_PLATFORM_COCOA) | ||||
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin); | Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin); | ||||
#endif | #endif | ||||
#endif | #endif | ||||
#include <cstdint> | |||||
#include <memory> | #include <memory> | ||||
// Declare meta types used for QMetaObject::invokeMethod | // Declare meta types used for QMetaObject::invokeMethod | ||||
Q_DECLARE_METATYPE(bool *) | Q_DECLARE_METATYPE(bool *) | ||||
Q_DECLARE_METATYPE(Amount) | Q_DECLARE_METATYPE(Amount) | ||||
Q_DECLARE_METATYPE(uint256) | Q_DECLARE_METATYPE(uint256) | ||||
// Config is non-copyable so we can only register pointers to it | // Config is non-copyable so we can only register pointers to it | ||||
▲ Show 20 Lines • Show All 494 Lines • ▼ Show 20 Lines | #endif | ||||
/// 2. Parse command-line options. We do this after qt in order to show an | /// 2. Parse command-line options. We do this after qt in order to show an | ||||
/// error if there are problems parsing these | /// error if there are problems parsing these | ||||
// Command-line options take precedence: | // Command-line options take precedence: | ||||
node->setupServerArgs(); | node->setupServerArgs(); | ||||
SetupUIArgs(); | SetupUIArgs(); | ||||
std::string error; | std::string error; | ||||
if (!node->parseParameters(argc, argv, error)) { | if (!node->parseParameters(argc, argv, error)) { | ||||
node->initError( | |||||
strprintf("Error parsing command line arguments: %s\n", error)); | |||||
// Create a message box, because the gui has neither been created nor | |||||
// has subscribed to core signals | |||||
QMessageBox::critical( | QMessageBox::critical( | ||||
nullptr, PACKAGE_NAME, | nullptr, PACKAGE_NAME, | ||||
QObject::tr("Error parsing command line arguments: %1.") | // message can not be translated because translations have not been | ||||
// initialized | |||||
QString::fromStdString("Error parsing command line arguments: %1.") | |||||
.arg(QString::fromStdString(error))); | .arg(QString::fromStdString(error))); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
// Now that the QApplication is setup and we have parsed our parameters, we | // Now that the QApplication is setup and we have parsed our parameters, we | ||||
// can set the platform style | // can set the platform style | ||||
app.setupPlatformStyle(); | app.setupPlatformStyle(); | ||||
Show All 31 Lines | #endif | ||||
if (!Intro::pickDataDirectory(*node)) { | if (!Intro::pickDataDirectory(*node)) { | ||||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||||
} | } | ||||
/// 6. Determine availability of data and blocks directory and parse | /// 6. Determine availability of data and blocks directory and parse | ||||
/// bitcoin.conf | /// bitcoin.conf | ||||
/// - Do not call GetDataDir(true) before this step finishes. | /// - Do not call GetDataDir(true) before this step finishes. | ||||
if (!fs::is_directory(GetDataDir(false))) { | if (!fs::is_directory(GetDataDir(false))) { | ||||
node->initError( | |||||
strprintf("Specified data directory \"%s\" does not exist.\n", | |||||
gArgs.GetArg("-datadir", ""))); | |||||
QMessageBox::critical( | QMessageBox::critical( | ||||
nullptr, PACKAGE_NAME, | nullptr, PACKAGE_NAME, | ||||
QObject::tr( | QObject::tr( | ||||
"Error: Specified data directory \"%1\" does not exist.") | "Error: Specified data directory \"%1\" does not exist.") | ||||
.arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); | .arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
if (!node->readConfigFiles(error)) { | if (!node->readConfigFiles(error)) { | ||||
node->initError( | |||||
strprintf("Error reading configuration file: %s\n", error)); | |||||
QMessageBox::critical( | QMessageBox::critical( | ||||
nullptr, PACKAGE_NAME, | nullptr, PACKAGE_NAME, | ||||
QObject::tr("Error: Cannot parse configuration file: %1.") | QObject::tr("Error: Cannot parse configuration file: %1.") | ||||
.arg(QString::fromStdString(error))); | .arg(QString::fromStdString(error))); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
/// 7. Determine network (and switch to network specific options) | /// 7. Determine network (and switch to network specific options) | ||||
// - Do not call Params() before this step. | // - Do not call Params() before this step. | ||||
// - Do this after parsing the configuration file, as the network can be | // - Do this after parsing the configuration file, as the network can be | ||||
// switched there. | // switched there. | ||||
// - QSettings() will use the new application name after this, resulting in | // - QSettings() will use the new application name after this, resulting in | ||||
// network-specific settings. | // network-specific settings. | ||||
// - Needs to be done before createOptionsModel. | // - Needs to be done before createOptionsModel. | ||||
// Check for -testnet or -regtest parameter (Params() calls are only valid | // Check for -testnet or -regtest parameter (Params() calls are only valid | ||||
// after this clause) | // after this clause) | ||||
try { | try { | ||||
node->selectParams(gArgs.GetChainName()); | node->selectParams(gArgs.GetChainName()); | ||||
} catch (std::exception &e) { | } catch (std::exception &e) { | ||||
node->initError(strprintf("%s\n", e.what())); | |||||
QMessageBox::critical(nullptr, PACKAGE_NAME, | QMessageBox::critical(nullptr, PACKAGE_NAME, | ||||
QObject::tr("Error: %1").arg(e.what())); | QObject::tr("Error: %1").arg(e.what())); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
// Parse URIs on command line -- this can affect Params() | // Parse URIs on command line -- this can affect Params() | ||||
PaymentServer::ipcParseCommandLine(*node, argc, argv); | PaymentServer::ipcParseCommandLine(*node, argc, argv); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |