Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show All 22 Lines | |||||
#include "winshutdownmonitor.h" | #include "winshutdownmonitor.h" | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
#include "paymentserver.h" | #include "paymentserver.h" | ||||
#include "walletmodel.h" | #include "walletmodel.h" | ||||
#endif | #endif | ||||
#include "init.h" | #include "init.h" | ||||
#include "interface/handler.h" | #include "interfaces/handler.h" | ||||
#include "interface/node.h" | #include "interfaces/node.h" | ||||
#include "rpc/server.h" | #include "rpc/server.h" | ||||
#include "ui_interface.h" | #include "ui_interface.h" | ||||
#include "uint256.h" | #include "uint256.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "warnings.h" | #include "warnings.h" | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
#include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Class encapsulating Bitcoin ABC startup and shutdown. | * Class encapsulating Bitcoin ABC startup and shutdown. | ||||
* Allows running startup and shutdown in a different thread from the UI thread. | * Allows running startup and shutdown in a different thread from the UI thread. | ||||
*/ | */ | ||||
class BitcoinABC : public QObject { | class BitcoinABC : public QObject { | ||||
Q_OBJECT | Q_OBJECT | ||||
public: | public: | ||||
explicit BitcoinABC(interface::Node &node); | explicit BitcoinABC(interfaces::Node &node); | ||||
public Q_SLOTS: | public Q_SLOTS: | ||||
void initialize(Config *config, | void initialize(Config *config, | ||||
HTTPRPCRequestProcessor *httpRPCRequestProcessor); | HTTPRPCRequestProcessor *httpRPCRequestProcessor); | ||||
void shutdown(); | void shutdown(); | ||||
Q_SIGNALS: | Q_SIGNALS: | ||||
void initializeResult(bool success); | void initializeResult(bool success); | ||||
void shutdownResult(); | void shutdownResult(); | ||||
void runawayException(const QString &message); | void runawayException(const QString &message); | ||||
private: | private: | ||||
/// Pass fatal exception message to UI thread | /// Pass fatal exception message to UI thread | ||||
void handleRunawayException(const std::exception *e); | void handleRunawayException(const std::exception *e); | ||||
interface::Node &m_node; | interfaces::Node &m_node; | ||||
}; | }; | ||||
/** Main Bitcoin application object */ | /** Main Bitcoin application object */ | ||||
class BitcoinApplication : public QApplication { | class BitcoinApplication : public QApplication { | ||||
Q_OBJECT | Q_OBJECT | ||||
public: | public: | ||||
explicit BitcoinApplication(interface::Node &node, int &argc, char **argv); | explicit BitcoinApplication(interfaces::Node &node, int &argc, char **argv); | ||||
~BitcoinApplication(); | ~BitcoinApplication(); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
/// Create payment server | /// Create payment server | ||||
void createPaymentServer(); | void createPaymentServer(); | ||||
#endif | #endif | ||||
/// parameter interaction/setup based on rules | /// parameter interaction/setup based on rules | ||||
void parameterSetup(); | void parameterSetup(); | ||||
Show All 27 Lines | Q_SIGNALS: | ||||
void requestedInitialize(Config *config, | void requestedInitialize(Config *config, | ||||
HTTPRPCRequestProcessor *httpRPCRequestProcessor); | HTTPRPCRequestProcessor *httpRPCRequestProcessor); | ||||
void requestedShutdown(); | void requestedShutdown(); | ||||
void stopThread(); | void stopThread(); | ||||
void splashFinished(QWidget *window); | void splashFinished(QWidget *window); | ||||
private: | private: | ||||
QThread *coreThread; | QThread *coreThread; | ||||
interface::Node &m_node; | interfaces::Node &m_node; | ||||
OptionsModel *optionsModel; | OptionsModel *optionsModel; | ||||
ClientModel *clientModel; | ClientModel *clientModel; | ||||
BitcoinGUI *window; | BitcoinGUI *window; | ||||
QTimer *pollShutdownTimer; | QTimer *pollShutdownTimer; | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
PaymentServer *paymentServer; | PaymentServer *paymentServer; | ||||
std::vector<WalletModel *> m_wallet_models; | std::vector<WalletModel *> m_wallet_models; | ||||
#endif | #endif | ||||
int returnValue; | int returnValue; | ||||
const PlatformStyle *platformStyle; | const PlatformStyle *platformStyle; | ||||
std::unique_ptr<QWidget> shutdownWindow; | std::unique_ptr<QWidget> shutdownWindow; | ||||
void startThread(); | void startThread(); | ||||
}; | }; | ||||
#include "bitcoin.moc" | #include "bitcoin.moc" | ||||
BitcoinABC::BitcoinABC(interface::Node &node) : QObject(), m_node(node) {} | BitcoinABC::BitcoinABC(interfaces::Node &node) : QObject(), m_node(node) {} | ||||
void BitcoinABC::handleRunawayException(const std::exception *e) { | void BitcoinABC::handleRunawayException(const std::exception *e) { | ||||
PrintExceptionContinue(e, "Runaway exception"); | PrintExceptionContinue(e, "Runaway exception"); | ||||
Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings("gui"))); | Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings("gui"))); | ||||
} | } | ||||
void BitcoinABC::initialize(Config *cfg, | void BitcoinABC::initialize(Config *cfg, | ||||
HTTPRPCRequestProcessor *httpRPCRequestProcessor) { | HTTPRPCRequestProcessor *httpRPCRequestProcessor) { | ||||
Show All 17 Lines | try { | ||||
Q_EMIT shutdownResult(); | Q_EMIT shutdownResult(); | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
handleRunawayException(&e); | handleRunawayException(&e); | ||||
} catch (...) { | } catch (...) { | ||||
handleRunawayException(nullptr); | handleRunawayException(nullptr); | ||||
} | } | ||||
} | } | ||||
BitcoinApplication::BitcoinApplication(interface::Node &node, int &argc, | BitcoinApplication::BitcoinApplication(interfaces::Node &node, int &argc, | ||||
char **argv) | char **argv) | ||||
: QApplication(argc, argv), coreThread(0), m_node(node), optionsModel(0), | : QApplication(argc, argv), coreThread(0), m_node(node), optionsModel(0), | ||||
clientModel(0), window(0), pollShutdownTimer(0), | clientModel(0), window(0), pollShutdownTimer(0), | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
paymentServer(0), m_wallet_models(), | paymentServer(0), m_wallet_models(), | ||||
#endif | #endif | ||||
returnValue(0) { | returnValue(0) { | ||||
setQuitOnLastWindowClosed(false); | setQuitOnLastWindowClosed(false); | ||||
▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | if (!legacyKeys.isEmpty() && abc.allKeys().isEmpty()) { | ||||
abc.setValue(key, legacy.value(key)); | abc.setValue(key, legacy.value(key)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||||
SetupEnvironment(); | SetupEnvironment(); | ||||
std::unique_ptr<interface::Node> node = interface::MakeNode(); | std::unique_ptr<interfaces::Node> node = interfaces::MakeNode(); | ||||
/// 1. Parse command-line options. These take precedence over anything else. | /// 1. Parse command-line options. These take precedence over anything else. | ||||
// Command-line options take precedence: | // Command-line options take precedence: | ||||
node->parseParameters(argc, argv); | node->parseParameters(argc, argv); | ||||
// Do not refer to data directory yet, this can be overridden by | // Do not refer to data directory yet, this can be overridden by | ||||
// Intro::pickDataDirectory | // Intro::pickDataDirectory | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | #endif | ||||
// Install qDebug() message handler to route to debug.log | // Install qDebug() message handler to route to debug.log | ||||
qInstallMessageHandler(DebugMessageHandler); | qInstallMessageHandler(DebugMessageHandler); | ||||
// Allow parameter interaction before we create the options model | // Allow parameter interaction before we create the options model | ||||
app.parameterSetup(); | app.parameterSetup(); | ||||
// Load GUI settings from QSettings | // Load GUI settings from QSettings | ||||
app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false)); | app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false)); | ||||
// Subscribe to global signals from core | // Subscribe to global signals from core | ||||
std::unique_ptr<interface::Handler> handler = | std::unique_ptr<interfaces::Handler> handler = | ||||
node->handleInitMessage(InitMessage); | node->handleInitMessage(InitMessage); | ||||
// Get global config | // Get global config | ||||
Config &config = const_cast<Config &>(GetConfig()); | Config &config = const_cast<Config &>(GetConfig()); | ||||
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && | if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && | ||||
!gArgs.GetBoolArg("-min", false)) { | !gArgs.GetBoolArg("-min", false)) { | ||||
app.createSplashScreen(networkStyle.data()); | app.createSplashScreen(networkStyle.data()); | ||||
Show All 38 Lines |