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