Bitcoin Core  0.19.99
P2P Digital Currency
bitcoin.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #if defined(HAVE_CONFIG_H)
7 #endif
8 
9 #include <qt/bitcoin.h>
10 #include <qt/bitcoingui.h>
11 
12 #include <chainparams.h>
13 #include <qt/clientmodel.h>
14 #include <qt/guiconstants.h>
15 #include <qt/guiutil.h>
16 #include <qt/intro.h>
17 #include <qt/networkstyle.h>
18 #include <qt/optionsmodel.h>
19 #include <qt/platformstyle.h>
20 #include <qt/splashscreen.h>
21 #include <qt/utilitydialog.h>
22 #include <qt/winshutdownmonitor.h>
23 
24 #ifdef ENABLE_WALLET
25 #include <qt/paymentserver.h>
26 #include <qt/walletcontroller.h>
27 #include <qt/walletmodel.h>
28 #endif // ENABLE_WALLET
29 
30 #include <interfaces/handler.h>
31 #include <interfaces/node.h>
32 #include <noui.h>
33 #include <ui_interface.h>
34 #include <uint256.h>
35 #include <util/system.h>
36 #include <util/threadnames.h>
37 
38 #include <memory>
39 
40 #include <QApplication>
41 #include <QDebug>
42 #include <QLibraryInfo>
43 #include <QLocale>
44 #include <QMessageBox>
45 #include <QSettings>
46 #include <QThread>
47 #include <QTimer>
48 #include <QTranslator>
49 
50 #if defined(QT_STATICPLUGIN)
51 #include <QtPlugin>
52 #if defined(QT_QPA_PLATFORM_XCB)
53 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
54 #elif defined(QT_QPA_PLATFORM_WINDOWS)
55 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
56 #elif defined(QT_QPA_PLATFORM_COCOA)
57 Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
58 #endif
59 #endif
60 
61 // Declare meta types used for QMetaObject::invokeMethod
62 Q_DECLARE_METATYPE(bool*)
63 Q_DECLARE_METATYPE(CAmount)
64 Q_DECLARE_METATYPE(uint256)
65 
66 static QString GetLangTerritory()
67 {
68  QSettings settings;
69  // Get desired locale (e.g. "de_DE")
70  // 1) System default language
71  QString lang_territory = QLocale::system().name();
72  // 2) Language from QSettings
73  QString lang_territory_qsettings = settings.value("language", "").toString();
74  if(!lang_territory_qsettings.isEmpty())
75  lang_territory = lang_territory_qsettings;
76  // 3) -lang command line argument
77  lang_territory = QString::fromStdString(gArgs.GetArg("-lang", lang_territory.toStdString()));
78  return lang_territory;
79 }
80 
82 static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator)
83 {
84  // Remove old translators
85  QApplication::removeTranslator(&qtTranslatorBase);
86  QApplication::removeTranslator(&qtTranslator);
87  QApplication::removeTranslator(&translatorBase);
88  QApplication::removeTranslator(&translator);
89 
90  // Get desired locale (e.g. "de_DE")
91  // 1) System default language
92  QString lang_territory = GetLangTerritory();
93 
94  // Convert to "de" only by truncating "_DE"
95  QString lang = lang_territory;
96  lang.truncate(lang_territory.lastIndexOf('_'));
97 
98  // Load language files for configured locale:
99  // - First load the translator for the base language, without territory
100  // - Then load the more specific locale translator
101 
102  // Load e.g. qt_de.qm
103  if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
104  QApplication::installTranslator(&qtTranslatorBase);
105 
106  // Load e.g. qt_de_DE.qm
107  if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
108  QApplication::installTranslator(&qtTranslator);
109 
110  // Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc)
111  if (translatorBase.load(lang, ":/translations/"))
112  QApplication::installTranslator(&translatorBase);
113 
114  // Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc)
115  if (translator.load(lang_territory, ":/translations/"))
116  QApplication::installTranslator(&translator);
117 }
118 
119 /* qDebug() message handler --> debug.log */
120 void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
121 {
122  Q_UNUSED(context);
123  if (type == QtDebugMsg) {
124  LogPrint(BCLog::QT, "GUI: %s\n", msg.toStdString());
125  } else {
126  LogPrintf("GUI: %s\n", msg.toStdString());
127  }
128 }
129 
131  QObject(), m_node(node)
132 {
133 }
134 
135 void BitcoinCore::handleRunawayException(const std::exception *e)
136 {
137  PrintExceptionContinue(e, "Runaway exception");
138  Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings()));
139 }
140 
142 {
143  try
144  {
145  qDebug() << __func__ << ": Running initialization in thread";
146  util::ThreadRename("qt-init");
147  bool rv = m_node.appInitMain();
148  Q_EMIT initializeResult(rv);
149  } catch (const std::exception& e) {
151  } catch (...) {
152  handleRunawayException(nullptr);
153  }
154 }
155 
157 {
158  try
159  {
160  qDebug() << __func__ << ": Running Shutdown in thread";
162  qDebug() << __func__ << ": Shutdown finished";
163  Q_EMIT shutdownResult();
164  } catch (const std::exception& e) {
166  } catch (...) {
167  handleRunawayException(nullptr);
168  }
169 }
170 
171 static int qt_argc = 1;
172 static const char* qt_argv = "bitcoin-qt";
173 
175  QApplication(qt_argc, const_cast<char **>(&qt_argv)),
176  coreThread(nullptr),
177  m_node(node),
178  optionsModel(nullptr),
179  clientModel(nullptr),
180  window(nullptr),
181  pollShutdownTimer(nullptr),
182  returnValue(0),
183  platformStyle(nullptr)
184 {
185  setQuitOnLastWindowClosed(false);
186 }
187 
189 {
190  // UI per-platform customization
191  // This must be done inside the BitcoinApplication constructor, or after it, because
192  // PlatformStyle::instantiate requires a QApplication
193  std::string platformName;
194  platformName = gArgs.GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM);
195  platformStyle = PlatformStyle::instantiate(QString::fromStdString(platformName));
196  if (!platformStyle) // Fall back to "other" if specified name not found
198  assert(platformStyle);
199 }
200 
202 {
203  if(coreThread)
204  {
205  qDebug() << __func__ << ": Stopping thread";
206  coreThread->quit();
207  coreThread->wait();
208  qDebug() << __func__ << ": Stopped thread";
209  }
210 
211  delete window;
212  window = nullptr;
213  delete optionsModel;
214  optionsModel = nullptr;
215  delete platformStyle;
216  platformStyle = nullptr;
217 }
218 
219 #ifdef ENABLE_WALLET
220 void BitcoinApplication::createPaymentServer()
221 {
222  paymentServer = new PaymentServer(this);
223 }
224 #endif
225 
227 {
228  optionsModel = new OptionsModel(m_node, nullptr, resetSettings);
229 }
230 
232 {
233  window = new BitcoinGUI(m_node, platformStyle, networkStyle, nullptr);
234 
235  pollShutdownTimer = new QTimer(window);
236  connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
237 }
238 
240 {
241  SplashScreen *splash = new SplashScreen(m_node, nullptr, networkStyle);
242  // We don't hold a direct pointer to the splash screen after creation, but the splash
243  // screen will take care of deleting itself when finish() happens.
244  splash->show();
246  connect(this, &BitcoinApplication::requestedShutdown, splash, &QWidget::close);
247 }
248 
250 {
251  return m_node.baseInitialize();
252 }
253 
255 {
256  if(coreThread)
257  return;
258  coreThread = new QThread(this);
259  BitcoinCore *executor = new BitcoinCore(m_node);
260  executor->moveToThread(coreThread);
261 
262  /* communication to and from thread */
268  /* make sure executor object is deleted in its own thread */
269  connect(coreThread, &QThread::finished, executor, &QObject::deleteLater);
270 
271  coreThread->start();
272 }
273 
275 {
276  // Default printtoconsole to false for the GUI. GUI programs should not
277  // print to the console unnecessarily.
278  gArgs.SoftSetBoolArg("-printtoconsole", false);
279 
282 }
283 
285 {
286  // If prune is set, intentionally override existing prune size with
287  // the default size since this is called when choosing a new datadir.
289 }
290 
292 {
293  qDebug() << __func__ << ": Requesting initialize";
294  startThread();
295  Q_EMIT requestedInitialize();
296 }
297 
299 {
300  // Show a simple window indicating shutdown status
301  // Do this first as some of the steps may take some time below,
302  // for example the RPC console may still be executing a command.
304 
305  qDebug() << __func__ << ": Requesting shutdown";
306  startThread();
307  window->hide();
308  // Must disconnect node signals otherwise current thread can deadlock since
309  // no event loop is running.
311  // Request node shutdown, which can interrupt long operations, like
312  // rescanning a wallet.
314  // Unsetting the client model can cause the current thread to wait for node
315  // to complete an operation, like wait for a RPC execution to complete.
316  window->setClientModel(nullptr);
317  pollShutdownTimer->stop();
318 
319  delete clientModel;
320  clientModel = nullptr;
321 
322  // Request shutdown from core thread
323  Q_EMIT requestedShutdown();
324 }
325 
327 {
328  qDebug() << __func__ << ": Initialization result: " << success;
329  // Set exit result.
330  returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE;
331  if(success)
332  {
333  // Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
334  qInfo() << "Platform customization:" << platformStyle->getName();
337 #ifdef ENABLE_WALLET
339  m_wallet_controller = new WalletController(m_node, platformStyle, optionsModel, this);
340  window->setWalletController(m_wallet_controller);
341  if (paymentServer) {
342  paymentServer->setOptionsModel(optionsModel);
343  }
344  }
345 #endif // ENABLE_WALLET
346 
347  // If -min option passed, start window minimized (iconified) or minimized to tray
348  if (!gArgs.GetBoolArg("-min", false)) {
349  window->show();
351  // do nothing as the window is managed by the tray icon
352  } else {
353  window->showMinimized();
354  }
355  Q_EMIT splashFinished();
356  Q_EMIT windowShown(window);
357 
358 #ifdef ENABLE_WALLET
359  // Now that initialization/startup is done, process any command-line
360  // bitcoin: URIs or payment requests:
361  if (paymentServer) {
362  connect(paymentServer, &PaymentServer::receivedPaymentRequest, window, &BitcoinGUI::handlePaymentRequest);
364  connect(paymentServer, &PaymentServer::message, [this](const QString& title, const QString& message, unsigned int style) {
365  window->message(title, message, style);
366  });
367  QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady);
368  }
369 #endif
370  pollShutdownTimer->start(200);
371  } else {
372  Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
373  quit(); // Exit first main loop invocation
374  }
375 }
376 
378 {
379  quit(); // Exit second main loop invocation after shutdown finished
380 }
381 
382 void BitcoinApplication::handleRunawayException(const QString &message)
383 {
384  QMessageBox::critical(nullptr, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + message);
385  ::exit(EXIT_FAILURE);
386 }
387 
389 {
390  if (!window)
391  return 0;
392 
393  return window->winId();
394 }
395 
396 static void SetupUIArgs()
397 {
398  gArgs.AddArg("-choosedatadir", strprintf("Choose data directory on startup (default: %u)", DEFAULT_CHOOSE_DATADIR), ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
399  gArgs.AddArg("-lang=<lang>", "Set language, for example \"de_DE\" (default: system locale)", ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
400  gArgs.AddArg("-min", "Start minimized", ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
401  gArgs.AddArg("-resetguisettings", "Reset all settings changed in the GUI", ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
402  gArgs.AddArg("-splash", strprintf("Show splash screen on startup (default: %u)", DEFAULT_SPLASHSCREEN), ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
403  gArgs.AddArg("-uiplatform", strprintf("Select platform to customize UI for (one of windows, macosx, other; default: %s)", BitcoinGUI::DEFAULT_UIPLATFORM), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::GUI);
404 }
405 
406 int GuiMain(int argc, char* argv[])
407 {
408 #ifdef WIN32
409  util::WinCmdLineArgs winArgs;
410  std::tie(argc, argv) = winArgs.get();
411 #endif
414 
415  std::unique_ptr<interfaces::Node> node = interfaces::MakeNode();
416 
417  // Subscribe to global signals from core
418  std::unique_ptr<interfaces::Handler> handler_message_box = node->handleMessageBox(noui_ThreadSafeMessageBox);
419  std::unique_ptr<interfaces::Handler> handler_question = node->handleQuestion(noui_ThreadSafeQuestion);
420  std::unique_ptr<interfaces::Handler> handler_init_message = node->handleInitMessage(noui_InitMessage);
421 
422  // Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
423 
425  Q_INIT_RESOURCE(bitcoin);
426  Q_INIT_RESOURCE(bitcoin_locale);
427 
428  // Generate high-dpi pixmaps
429  QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
430 #if QT_VERSION >= 0x050600
431  QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
432 #endif
433 
434  BitcoinApplication app(*node);
435 
436  // Register meta types used for QMetaObject::invokeMethod and Qt::QueuedConnection
437  qRegisterMetaType<bool*>();
438 #ifdef ENABLE_WALLET
439  qRegisterMetaType<WalletModel*>();
440 #endif
441  // Register typedefs (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
442  // IMPORTANT: if CAmount is no longer a typedef use the normal variant above (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1)
443  qRegisterMetaType<CAmount>("CAmount");
444  qRegisterMetaType<size_t>("size_t");
445 
446  qRegisterMetaType<std::function<void()>>("std::function<void()>");
447  qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
448 
450  // Command-line options take precedence:
451  node->setupServerArgs();
452  SetupUIArgs();
453  std::string error;
454  if (!node->parseParameters(argc, argv, error)) {
455  node->initError(strprintf("Error parsing command line arguments: %s\n", error));
456  // Create a message box, because the gui has neither been created nor has subscribed to core signals
457  QMessageBox::critical(nullptr, PACKAGE_NAME,
458  // message can not be translated because translations have not been initialized
459  QString::fromStdString("Error parsing command line arguments: %1.").arg(QString::fromStdString(error)));
460  return EXIT_FAILURE;
461  }
462 
463  // Now that the QApplication is setup and we have parsed our parameters, we can set the platform style
464  app.setupPlatformStyle();
465 
467  // must be set before OptionsModel is initialized or translations are loaded,
468  // as it is used to locate QSettings
469  QApplication::setOrganizationName(QAPP_ORG_NAME);
470  QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN);
471  QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT);
472 
474  // Now that QSettings are accessible, initialize translations
475  QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
476  initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
477 
478  // Show help message immediately after parsing command-line options (for "-lang") and setting locale,
479  // but before showing splash screen.
480  if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
481  HelpMessageDialog help(*node, nullptr, gArgs.IsArgSet("-version"));
482  help.showOrPrint();
483  return EXIT_SUCCESS;
484  }
485 
487  // User language is set up: pick a data directory
488  bool did_show_intro = false;
489  bool prune = false; // Intro dialog prune check box
490  // Gracefully exit if the user cancels
491  if (!Intro::showIfNeeded(*node, did_show_intro, prune)) return EXIT_SUCCESS;
492 
495  if (!CheckDataDirOption()) {
496  node->initError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")));
497  QMessageBox::critical(nullptr, PACKAGE_NAME,
498  QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
499  return EXIT_FAILURE;
500  }
501  if (!node->readConfigFiles(error)) {
502  node->initError(strprintf("Error reading configuration file: %s\n", error));
503  QMessageBox::critical(nullptr, PACKAGE_NAME,
504  QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
505  return EXIT_FAILURE;
506  }
507 
509  // - Do not call Params() before this step
510  // - Do this after parsing the configuration file, as the network can be switched there
511  // - QSettings() will use the new application name after this, resulting in network-specific settings
512  // - Needs to be done before createOptionsModel
513 
514  // Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
515  try {
516  node->selectParams(gArgs.GetChainName());
517  } catch(std::exception &e) {
518  node->initError(strprintf("%s\n", e.what()));
519  QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what()));
520  return EXIT_FAILURE;
521  }
522 #ifdef ENABLE_WALLET
523  // Parse URIs on command line -- this can affect Params()
524  PaymentServer::ipcParseCommandLine(*node, argc, argv);
525 #endif
526 
527  QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(Params().NetworkIDString()));
528  assert(!networkStyle.isNull());
529  // Allow for separate UI settings for testnets
530  QApplication::setApplicationName(networkStyle->getAppName());
531  // Re-initialize translations after changing application name (language in network-specific settings can be different)
532  initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
533 
534 #ifdef ENABLE_WALLET
535  // - Do this early as we don't want to bother initializing if we are just calling IPC
537  // - Do this *after* setting up the data directory, as the data directory hash is used in the name
538  // of the server.
539  // - Do this after creating app and setting up translations, so errors are
540  // translated properly.
542  exit(EXIT_SUCCESS);
543 
544  // Start up the payment server early, too, so impatient users that click on
545  // bitcoin: links repeatedly have their payment requests routed to this process:
547  app.createPaymentServer();
548  }
549 #endif // ENABLE_WALLET
550 
552  // Install global event filter that makes sure that long tooltips can be word-wrapped
553  app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
554 #if defined(Q_OS_WIN)
555  // Install global event filter for processing Windows session related Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION)
556  qApp->installNativeEventFilter(new WinShutdownMonitor());
557 #endif
558  // Install qDebug() message handler to route to debug.log
559  qInstallMessageHandler(DebugMessageHandler);
560  // Allow parameter interaction before we create the options model
561  app.parameterSetup();
563  // Load GUI settings from QSettings
564  app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false));
565 
566  if (did_show_intro) {
567  // Store intro dialog settings other than datadir (network specific)
568  app.InitializePruneSetting(prune);
569  }
570 
571  if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
572  app.createSplashScreen(networkStyle.data());
573 
574  int rv = EXIT_SUCCESS;
575  try
576  {
577  app.createWindow(networkStyle.data());
578  // Perform base initialization before spinning up initialization/shutdown thread
579  // This is acceptable because this function only contains steps that are quick to execute,
580  // so the GUI thread won't be held up.
581  if (app.baseInitialize()) {
582  app.requestInitialize();
583 #if defined(Q_OS_WIN)
584  WinShutdownMonitor::registerShutdownBlockReason(QObject::tr("%1 didn't yet exit safely...").arg(PACKAGE_NAME), (HWND)app.getMainWinId());
585 #endif
586  app.exec();
587  app.requestShutdown();
588  app.exec();
589  rv = app.getReturnValue();
590  } else {
591  // A dialog with detailed error will have been shown by InitError()
592  rv = EXIT_FAILURE;
593  }
594  } catch (const std::exception& e) {
595  PrintExceptionContinue(&e, "Runaway exception");
596  app.handleRunawayException(QString::fromStdString(node->getWarnings()));
597  } catch (...) {
598  PrintExceptionContinue(nullptr, "Runaway exception");
599  app.handleRunawayException(QString::fromStdString(node->getWarnings()));
600  }
601  return rv;
602 }
OptionsModel * optionsModel
Definition: bitcoin.h:108
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
static const bool DEFAULT_CHOOSE_DATADIR
Definition: intro.h:12
virtual bool appInitMain()=0
Start node.
static void SetupUIArgs()
Definition: bitcoin.cpp:396
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition: system.cpp:362
static constexpr int DEFAULT_PRUNE_TARGET_GB
Definition: guiconstants.h:55
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:188
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
void LogQtInfo()
Writes to debug.log short info about the used Qt and the host system.
Definition: guiutil.cpp:888
void message(const QString &title, const QString &message, unsigned int style)
#define LogPrint(category,...)
Definition: logging.h:179
virtual void initLogging()=0
Init logging.
static int qt_argc
Definition: bitcoin.cpp:171
bool noui_ThreadSafeQuestion(const std::string &, const std::string &message, const std::string &caption, unsigned int style)
Non-GUI handler, which logs and prints questions.
Definition: noui.cpp:52
static bool isWalletEnabled()
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn&#39;t already have a value.
Definition: system.cpp:398
Class for the splashscreen with information of the running client.
Definition: splashscreen.h:26
static const NetworkStyle * instantiate(const std::string &networkId)
Get style associated with provided network id, or 0 if not known.
Class encapsulating Bitcoin Core startup and shutdown.
Definition: bitcoin.h:32
virtual bool baseInitialize()=0
Initialize app dependencies.
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
void parameterSetup()
parameter interaction/setup based on rules
Definition: bitcoin.cpp:274
static void ipcParseCommandLine(interfaces::Node &node, int argc, char *argv[])
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
Definition: bitcoin.cpp:135
virtual void startShutdown()=0
Start shutdown.
NodeContext & m_node
Definition: chain.cpp:374
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
Definition: bitcoin.cpp:382
void SetPruneTargetGB(int prune_target_gb, bool force=false)
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name...
Definition: threadnames.cpp:57
void SetupEnvironment()
Definition: system.cpp:1074
void requestInitialize()
Request core initialization.
Definition: bitcoin.cpp:291
static void LogPrintf(const char *fmt, const Args &... args)
Definition: logging.h:163
#define PACKAGE_NAME
Controller between interfaces::Node, WalletModel instances and the GUI.
OptionsModel * getOptionsModel()
void receivedPaymentRequest(SendCoinsRecipient)
Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text repre...
Definition: guiutil.h:137
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:384
Bitcoin GUI main class.
Definition: bitcoingui.h:64
interfaces::Node & m_node
Definition: bitcoin.h:51
void createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:226
void noui_InitMessage(const std::string &message)
Non-GUI handler, which only logs a message.
Definition: noui.cpp:57
void requestedInitialize()
void initializeResult(bool success)
static const bool DEFAULT_SPLASHSCREEN
Definition: guiconstants.h:19
void handleURIOrFile(const QString &s)
static bool ipcSendCommandLine()
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
bool CheckDataDirOption()
Definition: system.cpp:642
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: bitcoingui.cpp:548
void shutdown()
Definition: bitcoin.cpp:156
static QWidget * showShutdownWindow(QMainWindow *window)
BitcoinCore(interfaces::Node &node)
Definition: bitcoin.cpp:130
void finish()
Hide the splash screen window and schedule the splash screen object for deletion. ...
#define QAPP_ORG_NAME
Definition: guiconstants.h:45
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:239
Main Bitcoin application object.
Definition: bitcoin.h:55
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:406
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:412
bool HelpRequested(const ArgsManager &args)
Definition: system.cpp:507
BitcoinApplication(interfaces::Node &node)
Definition: bitcoin.cpp:174
interfaces::Node & m_node
Definition: bitcoin.h:107
static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator)
Set up translations.
Definition: bitcoin.cpp:82
void detectShutdown()
called by a timer to check if ShutdownRequested() has been set
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:118
UniValue help(const JSONRPCRequest &jsonRequest)
Definition: server.cpp:130
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
Definition: system.cpp:549
static bool showIfNeeded(interfaces::Node &node, bool &did_show_intro, bool &prune)
Determine data directory.
Definition: intro.cpp:184
void initialize()
Definition: bitcoin.cpp:141
void windowShown(BitcoinGUI *window)
Model for Bitcoin network client.
Definition: clientmodel.h:44
void message(const QString &title, QString message, unsigned int style, bool *ret=nullptr)
Notify the user of an event from the core network or transaction handling code.
void shutdownResult()
Definition: bitcoin.cpp:377
bool hasTrayIcon() const
Get the tray icon status.
Definition: bitcoingui.h:96
void ThreadSetInternalName(std::string &&)
Set the internal (in-memory) name of the current thread only.
Definition: threadnames.cpp:63
static const char * qt_argv
Definition: bitcoin.cpp:172
BitcoinGUI * window
Definition: bitcoin.h:110
void requestShutdown()
Request core shutdown.
Definition: bitcoin.cpp:298
QThread * coreThread
Definition: bitcoin.h:106
virtual void initParameterInteraction()=0
Init parameter interaction.
void DebugMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
Definition: bitcoin.cpp:120
256-bit opaque blob.
Definition: uint256.h:120
#define QAPP_APP_NAME_DEFAULT
Definition: guiconstants.h:47
virtual void appShutdown()=0
Stop node.
void createWindow(const NetworkStyle *networkStyle)
Create main window.
Definition: bitcoin.cpp:231
static const int TOOLTIP_WRAP_THRESHOLD
Definition: guiconstants.h:40
static const PlatformStyle * instantiate(const QString &platformId)
Get style associated with provided platform name, or 0 if not known.
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:36
#define QAPP_ORG_DOMAIN
Definition: guiconstants.h:46
void initializeResult(bool success)
Definition: bitcoin.cpp:326
std::unique_ptr< Node > MakeNode()
Return implementation of Node interface.
Definition: node.cpp:327
const CChainParams & Params()
Return the currently selected parameters.
const QString & getName() const
Definition: platformstyle.h:19
bool getMinimizeToTray() const
Definition: optionsmodel.h:79
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:372
ArgsManager gArgs
Definition: system.cpp:76
"Help message" dialog box
Definition: utilitydialog.h:24
std::string GetChainName() const
Returns the appropriate chain name from the program arguments.
Definition: system.cpp:823
bool noui_ThreadSafeMessageBox(const std::string &message, const std::string &caption, unsigned int style)
Non-GUI handler, which logs and prints messages.
Definition: noui.cpp:21
virtual std::string getWarnings()=0
Get warnings.
void shutdownResult()
static QString GetLangTerritory()
Definition: bitcoin.cpp:66
void InitializePruneSetting(bool prune)
Initialize prune setting.
Definition: bitcoin.cpp:284
static const std::string DEFAULT_UIPLATFORM
Definition: bitcoingui.h:69
void runawayException(const QString &message)
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:388
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:39
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
bool baseInitialize()
Basic initialization, before starting initialization/shutdown thread. Return true on success...
Definition: bitcoin.cpp:249
ClientModel * clientModel
Definition: bitcoin.h:109
int getReturnValue() const
Get process return value.
Definition: bitcoin.h:85
QTimer * pollShutdownTimer
Definition: bitcoin.h:111
const PlatformStyle * platformStyle
Definition: bitcoin.h:117