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