PIVX Core  5.6.99
P2P Digital Currency
pivx.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 The Bitcoin developers
2 // Copyright (c) 2014-2015 The Dash developers
3 // Copyright (c) 2015-2022 The PIVX Core developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #if defined(HAVE_CONFIG_H)
8 #include "config/pivx-config.h"
9 #endif
10 
11 #include "pivxgui.h"
12 
13 #include "fs.h"
14 #include "guiinterface.h"
15 #include "init.h"
16 #include "net.h"
17 #include "qt/clientmodel.h"
18 #include "qt/guiconstants.h"
19 #include "qt/guiutil.h"
20 #include "qt/intro.h"
21 #include "qt/networkstyle.h"
22 #include "qt/optionsmodel.h"
23 #include "qt/winshutdownmonitor.h"
24 #include "rpc/server.h"
25 #include "shutdown.h"
26 #include "splash.h"
27 #include "util/system.h"
28 #include "utilitydialog.h"
29 #include "warnings.h"
30 #include "welcomecontentwidget.h"
31 
32 #ifdef ENABLE_WALLET
33 #include "governancemodel.h"
34 #include "mnmodel.h"
35 #include "paymentserver.h"
36 #include "walletmodel.h"
37 #include "interfaces/wallet.h"
38 #include "wallet/walletutil.h"
39 #include "wallet/wallet.h"
40 #endif
41 
42 #include <atomic>
43 
44 #include <QApplication>
45 #include <QLibraryInfo>
46 #include <QLocale>
47 #include <QMessageBox>
48 #include <QProcess>
49 #include <QSettings>
50 #include <QThread>
51 #include <QTimer>
52 #include <QTranslator>
53 
54 #if defined(QT_STATICPLUGIN)
55 #include <QtPlugin>
56 #if defined(QT_QPA_PLATFORM_XCB)
57 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
58 #elif defined(QT_QPA_PLATFORM_WINDOWS)
59 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
60 #elif defined(QT_QPA_PLATFORM_COCOA)
61 Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
62 #endif
63 Q_IMPORT_PLUGIN(QSvgPlugin);
64 Q_IMPORT_PLUGIN(QSvgIconPlugin);
65 Q_IMPORT_PLUGIN(QGifPlugin);
66 #endif
67 
68 // Declare meta types used for QMetaObject::invokeMethod
69 Q_DECLARE_METATYPE(bool*)
71 Q_DECLARE_METATYPE(interfaces::WalletBalances);
73 
74 static void InitMessage(const std::string& message)
75 {
76  LogPrintf("init message: %s\n", message);
77 }
78 
79 /*
80  Translate string to current locale using Qt.
81  */
82 static std::string Translate(const char* psz)
83 {
84  return QCoreApplication::translate("pivx-core", psz).toStdString();
85 }
86 
87 static QString GetLangTerritory(bool forceLangFromSetting = false)
88 {
89  QSettings settings;
90  // Get desired locale (e.g. "de_DE")
91  // 1) System default language
92  QString lang_territory = QLocale::system().name();
93  // 2) Language from QSettings
94  QString lang_territory_qsettings = settings.value("language", "").toString();
95  if (!lang_territory_qsettings.isEmpty())
96  lang_territory = lang_territory_qsettings;
97  // 3) -lang command line argument
98  lang_territory = QString::fromStdString(gArgs.GetArg("-lang", lang_territory.toStdString()));
99  return (forceLangFromSetting) ? lang_territory_qsettings : lang_territory;
100 }
101 
103 static void initTranslations(QTranslator& qtTranslatorBase, QTranslator& qtTranslator, QTranslator& translatorBase, QTranslator& translator, bool forceLangFromSettings = false)
104 {
105  // Remove old translators
106  QApplication::removeTranslator(&qtTranslatorBase);
107  QApplication::removeTranslator(&qtTranslator);
108  QApplication::removeTranslator(&translatorBase);
109  QApplication::removeTranslator(&translator);
110 
111  // Get desired locale (e.g. "de_DE")
112  // 1) System default language
113  QString lang_territory = GetLangTerritory(forceLangFromSettings);
114 
115  // Convert to "de" only by truncating "_DE"
116  QString lang = lang_territory;
117  lang.truncate(lang_territory.lastIndexOf('_'));
118 
119  // Load language files for configured locale:
120  // - First load the translator for the base language, without territory
121  // - Then load the more specific locale translator
122 
123  // Load e.g. qt_de.qm
124  if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
125  QApplication::installTranslator(&qtTranslatorBase);
126 
127  // Load e.g. qt_de_DE.qm
128  if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
129  QApplication::installTranslator(&qtTranslator);
130 
131  // Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in pivx.qrc)
132  if (translatorBase.load(lang, ":/translations/"))
133  QApplication::installTranslator(&translatorBase);
134 
135  // Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in pivx.qrc)
136  if (translator.load(lang_territory, ":/translations/"))
137  QApplication::installTranslator(&translator);
138 }
139 
140 /* qDebug() message handler --> debug.log */
141 void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
142 {
143  Q_UNUSED(context);
144  if (type == QtDebugMsg) {
145  LogPrint(BCLog::QT, "GUI: %s\n", msg.toStdString());
146  } else {
147  LogPrintf("GUI: %s\n", msg.toStdString());
148  }
149 }
150 
154 class BitcoinCore : public QObject
155 {
156  Q_OBJECT
157 public:
158  explicit BitcoinCore();
159 
160 public Q_SLOTS:
161  void initialize();
162  void shutdown();
163  bool shutdownFromThread(const QString& type = "Shutdown");
164  void restart(const QStringList& args);
165 
166 Q_SIGNALS:
167  void initializeResult(int retval);
168  void shutdownResult(int retval);
169  void runawayException(const QString& message);
170 
171 private:
173  void handleRunawayException(const std::exception* e);
174 };
175 
177 class BitcoinApplication : public QApplication
178 {
179  Q_OBJECT
180 public:
181  explicit BitcoinApplication(int& argc, char** argv);
183 
184 #ifdef ENABLE_WALLET
186  void createPaymentServer();
187 #endif
189  void parameterSetup();
191  void createOptionsModel();
193  void createWindow(const NetworkStyle* networkStyle);
195  void createSplashScreen(const NetworkStyle* networkStyle);
196 
198  bool createTutorialScreen();
199 
201  void requestInitialize();
203  void requestShutdown();
204 
206  int getReturnValue() { return returnValue; }
207 
209  WId getMainWinId() const;
210 
211 public Q_SLOTS:
212  void initializeResult(int retval);
213  void shutdownResult(int retval);
215  void handleRunawayException(const QString& message);
216  void updateTranslation(bool forceLangFromSettings = false);
217 
218 Q_SIGNALS:
220  void requestedRestart(QStringList args);
222  void stopThread();
223  void splashFinished(QWidget* window);
224 
225 private:
226  QThread* coreThread{nullptr};
229  PIVXGUI* window{nullptr};
230  QTimer* pollShutdownTimer{nullptr};
231 #ifdef ENABLE_WALLET
232  PaymentServer* paymentServer{nullptr};
233  WalletModel* walletModel{nullptr};
234  GovernanceModel* govModel{nullptr};
235  MNModel* mnModel{nullptr};
236 #endif
237  int returnValue{0};
239 
240  void startThread();
241 };
242 
243 #include "pivx.moc"
244 
246 {
247 }
248 
249 void BitcoinCore::handleRunawayException(const std::exception* e)
250 {
251  PrintExceptionContinue(e, "Runaway exception");
252  Q_EMIT runawayException(QString::fromStdString(GetWarnings("gui")));
253 }
254 
256 {
257  try {
258  qDebug() << __func__ << ": Running AppInit2 in thread";
259  if (!AppInitBasicSetup()) {
260  Q_EMIT initializeResult(false);
261  return;
262  }
264  Q_EMIT initializeResult(false);
265  return;
266  }
267  if (!AppInitSanityChecks()) {
268  Q_EMIT initializeResult(false);
269  return;
270  }
271  int rv = AppInitMain();
272  Q_EMIT initializeResult(rv);
273  } catch (const std::exception& e) {
275  } catch (...) {
276  handleRunawayException(nullptr);
277  }
278 }
279 
280 void BitcoinCore::restart(const QStringList& args)
281 {
282  static std::atomic<bool> restartAvailable{true};
283  if (restartAvailable.exchange(false)) {
284  if (!shutdownFromThread("restart")) {
285  qDebug() << __func__ << ": Restart failed...";
286  return;
287  }
288  // Forced cleanup.
291  QProcess::startDetached(QApplication::applicationFilePath(), args);
292  qDebug() << __func__ << ": Restart initiated...";
293  QApplication::quit();
294  }
295 }
296 
298 {
299  shutdownFromThread("Shutdown");
300 }
301 
302 bool BitcoinCore::shutdownFromThread(const QString& type)
303 {
304  try {
305  qDebug() << __func__ << ": Running "+type+" in thread";
306  Interrupt();
307  Shutdown();
308  qDebug() << __func__ << ": "+type+" finished";
309  Q_EMIT shutdownResult(1);
310  return true;
311  } catch (const std::exception& e) {
313  } catch (...) {
314  handleRunawayException(nullptr);
315  }
316  return false;
317 }
318 
319 BitcoinApplication::BitcoinApplication(int& argc, char** argv) : QApplication(argc, argv),
320  coreThread(nullptr),
321  optionsModel(nullptr),
322  clientModel(nullptr),
323  window(nullptr),
324  pollShutdownTimer(nullptr),
325 #ifdef ENABLE_WALLET
326  paymentServer(nullptr),
327  walletModel(nullptr),
328 #endif
329  returnValue(0)
330 {
331  setQuitOnLastWindowClosed(false);
332 }
333 
335 {
336  if (coreThread) {
337  qDebug() << __func__ << ": Stopping thread";
338  Q_EMIT stopThread();
339  coreThread->wait();
340  qDebug() << __func__ << ": Stopped thread";
341  }
342 
343  delete window;
344  window = nullptr;
345 #ifdef ENABLE_WALLET
346  delete paymentServer;
347  paymentServer = nullptr;
348 #endif
349  // Delete Qt-settings if user clicked on "Reset Options"
350  QSettings settings;
352  settings.clear();
353  settings.sync();
354  }
355  delete optionsModel;
356  optionsModel = nullptr;
357 }
358 
359 #ifdef ENABLE_WALLET
360 void BitcoinApplication::createPaymentServer()
361 {
362  paymentServer = new PaymentServer(this);
363 }
364 #endif
365 
367 {
368  optionsModel = new OptionsModel();
369 }
370 
372 {
373  window = new PIVXGUI(networkStyle, nullptr);
374 
375  pollShutdownTimer = new QTimer(window);
376  connect(pollShutdownTimer, &QTimer::timeout, window, &PIVXGUI::detectShutdown);
377 }
378 
380 {
381  Splash* splash = new Splash(networkStyle);
382  // We don't hold a direct pointer to the splash screen after creation, so use
383  // Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
384  splash->setAttribute(Qt::WA_DeleteOnClose);
385  splash->show();
386  connect(this, &BitcoinApplication::splashFinished, splash, &Splash::slotFinish);
387  connect(this, &BitcoinApplication::requestedShutdown, splash, &QWidget::close);
388 }
389 
391 {
393 
394  connect(widget, &WelcomeContentWidget::onLanguageSelected, [this](){
395  updateTranslation(true);
396  });
397 
398  widget->exec();
399  bool ret = widget->isOk;
400  widget->deleteLater();
401  return ret;
402 }
403 
404 void BitcoinApplication::updateTranslation(bool forceLangFromSettings){
405  // Re-initialize translations after change them
406  initTranslations(this->qtTranslatorBase, this->qtTranslator, this->translatorBase, this->translator, forceLangFromSettings);
407 }
408 
410 {
411  if (coreThread)
412  return;
413  coreThread = new QThread(this);
414  BitcoinCore* executor = new BitcoinCore();
415  executor->moveToThread(coreThread);
416 
417  /* communication to and from thread */
424  /* make sure executor object is deleted in its own thread */
425  connect(this, &BitcoinApplication::stopThread, executor, &QObject::deleteLater);
426  connect(this, &BitcoinApplication::stopThread, coreThread, &QThread::quit);
427 
428  coreThread->start();
429 }
430 
432 {
433  // Default printtoconsole to false for the GUI. GUI programs should not
434  // print to the console unnecessarily.
435  gArgs.SoftSetBoolArg("-printtoconsole", false);
436 
437  InitLogging();
439 }
440 
442 {
443  qDebug() << __func__ << ": Requesting initialize";
444  startThread();
445  Q_EMIT requestedInitialize();
446 }
447 
449 {
450  qDebug() << __func__ << ": Requesting shutdown";
451  startThread();
452  window->hide();
453  if (govModel) govModel->stop();
454  if (walletModel) walletModel->stop();
455  window->setClientModel(nullptr);
456  pollShutdownTimer->stop();
457 
458 #ifdef ENABLE_WALLET
459  window->removeAllWallets();
460  delete walletModel;
461  walletModel = nullptr;
462 #endif
463  delete clientModel;
464  clientModel = nullptr;
465 
466  // Show a simple window indicating shutdown status
468 
469  StartShutdown();
470 
471  // Request shutdown from core thread
472  Q_EMIT requestedShutdown();
473 }
474 
476 {
477  qDebug() << __func__ << ": Initialization result: " << retval;
478  // Set exit result: 0 if successful, 1 if failure
479  returnValue = retval ? 0 : 1;
480  if (retval) {
481 #ifdef ENABLE_WALLET
482  paymentServer->setOptionsModel(optionsModel);
483 #endif
484 
487 
488 #ifdef ENABLE_WALLET
489  mnModel = new MNModel(this);
490  govModel = new GovernanceModel(clientModel, mnModel);
491  // TODO: Expose secondary wallets
492  if (!vpwallets.empty()) {
493  walletModel = new WalletModel(vpwallets[0], optionsModel);
494  walletModel->setClientModel(clientModel);
495  mnModel->setWalletModel(walletModel);
496  govModel->setWalletModel(walletModel);
497  walletModel->init();
498  mnModel->init();
499 
500  window->setGovModel(govModel);
501  window->addWallet(PIVXGUI::DEFAULT_WALLET, walletModel);
502  window->setCurrentWallet(PIVXGUI::DEFAULT_WALLET);
503  window->setMNModel(mnModel);
504  }
505 #endif
506 
507  // If -min option passed, start window minimized.
508  if (gArgs.GetBoolArg("-min", false)) {
509  window->showMinimized();
510  } else {
511  window->show();
512  }
513  Q_EMIT splashFinished(window);
514 
515 #ifdef ENABLE_WALLET
516  // Now that initialization/startup is done, process any command-line
517  // PIVX: URIs or payment requests:
518  //connect(paymentServer, &PaymentServer::receivedPaymentRequest, window, &PIVXGUI::handlePaymentRequest);
519  connect(window, &PIVXGUI::receivedURI, paymentServer, &PaymentServer::handleURIOrFile);
520  connect(paymentServer, &PaymentServer::message, [this](const QString& title, const QString& message, unsigned int style) {
521  window->message(title, message, style);
522  });
523  QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady);
524 #endif
525  pollShutdownTimer->start(200);
526  } else {
527  quit(); // Exit main loop
528  }
529 }
530 
532 {
533  qDebug() << __func__ << ": Shutdown result: " << retval;
534  quit(); // Exit main loop after shutdown finished
535 }
536 
537 void BitcoinApplication::handleRunawayException(const QString& message)
538 {
539  QMessageBox::critical(nullptr, "Runaway exception", QObject::tr("A fatal error occurred. PIVX can no longer continue safely and will quit.") + QString("\n\n") + message);
540  ::exit(EXIT_FAILURE);
541 }
542 
544 {
545  if (!window)
546  return 0;
547 
548  return window->winId();
549 }
550 
551 #ifndef BITCOIN_QT_TEST
552 int main(int argc, char* argv[])
553 {
554 #ifdef WIN32
555  util::WinCmdLineArgs winArgs;
556  std::tie(argc, argv) = winArgs.get();
557 #endif
559 
561  // Command-line options take precedence:
562  gArgs.ParseParameters(argc, argv);
563 
564 // Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
565 
567  Q_INIT_RESOURCE(pivx_locale);
568  Q_INIT_RESOURCE(pivx);
569 
570  // Generate high-dpi pixmaps
571  QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
572 #if QT_VERSION >= 0x050600
573  QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
574 #endif
575 #ifdef Q_OS_MAC
576  QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
577 #endif
578  BitcoinApplication app(argc, argv);
579 
580  // Register meta types used for QMetaObject::invokeMethod
581  qRegisterMetaType<bool*>();
582  // Need to pass name here as CAmount is a typedef (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
583  // IMPORTANT if it is no longer a typedef use the normal variant above
584  qRegisterMetaType<CAmount>("CAmount");
585  qRegisterMetaType<CAmount>("interfaces::WalletBalances");
586  qRegisterMetaType<size_t>("size_t");
587 
589  // must be set before OptionsModel is initialized or translations are loaded,
590  // as it is used to locate QSettings
591  QApplication::setOrganizationName(QAPP_ORG_NAME);
592  QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN);
593  QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT);
594 
596  // Now that QSettings are accessible, initialize translations
597  //initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
598  app.updateTranslation();
599  translationInterface.Translate.connect(Translate);
600 
601  // Show help message immediately after parsing command-line options (for "-lang") and setting locale,
602  // but before showing splash screen.
603  if (gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version")) {
604  HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version"));
605  help.showOrPrint();
606  return EXIT_SUCCESS;
607  }
608 
610  // User language is set up: pick a data directory
612  return EXIT_SUCCESS;
613 
616  if (!CheckDataDirOption()) {
617  QMessageBox::critical(nullptr, PACKAGE_NAME,
618  QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
619  return EXIT_FAILURE;
620  }
621  try {
623  } catch (const std::exception& e) {
624  QMessageBox::critical(nullptr, PACKAGE_NAME,
625  QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
626  return EXIT_FAILURE;
627  }
628 
630  // - Do not call Params() before this step
631  // - Do this after parsing the configuration file, as the network can be switched there
632  // - QSettings() will use the new application name after this, resulting in network-specific settings
633  // - Needs to be done before createOptionsModel
634 
635  // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
636  try {
638  } catch(const std::exception& e) {
639  QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what()));
640  return EXIT_FAILURE;
641  }
642 #ifdef ENABLE_WALLET
643  // Parse URIs on command line -- this can affect Params()
645 #endif
646 
647  QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(QString::fromStdString(Params().NetworkIDString())));
648  assert(!networkStyle.isNull());
649  // Allow for separate UI settings for testnets
650  QApplication::setApplicationName(networkStyle->getAppName());
651  // Re-initialize translations after changing application name (language in network-specific settings can be different)
652  app.updateTranslation();
653 
654 #ifdef ENABLE_WALLET
656  // - Do this early as we don't want to bother initializing if we are just calling IPC
657  // - Do this *after* setting up the data directory, as the data directory hash is used in the name
658  // of the server.
659  // - Do this after creating app and setting up translations, so errors are
660  // translated properly.
662  exit(EXIT_SUCCESS);
663 
664  // Start up the payment server early, too, so impatient users that click on
665  // pivx: links repeatedly have their payment requests routed to this process:
666  app.createPaymentServer();
667 #endif
668 
670  // Install global event filter that makes sure that long tooltips can be word-wrapped
671  app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
672 #if defined(Q_OS_WIN)
673  // Install global event filter for processing Windows session related Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION)
674  qApp->installNativeEventFilter(new WinShutdownMonitor());
675 #endif
676  // Install qDebug() message handler to route to debug.log
677  qInstallMessageHandler(DebugMessageHandler);
678  // Allow parameter interaction before we create the options model
679  app.parameterSetup();
680  // Load GUI settings from QSettings
681  app.createOptionsModel();
682 
683  // Subscribe to global signals from core
684  uiInterface.InitMessage.connect(InitMessage);
685 
686  bool ret = true;
687 #ifdef ENABLE_WALLET
688  // Check if at least one wallet exists, otherwise prompt tutorial
689  bool createTutorial{true};
690  const fs::path wallet_dir = GetWalletDir();
691  gArgs.SoftSetArg("-wallet", "");
692  for (const std::string& wallet_name : gArgs.GetArgs("-wallet")) {
693  auto opRes = VerifyWalletPath(wallet_name);
694  if (!opRes) throw std::runtime_error(opRes.getError());
695  fs::path wallet_path = fs::absolute(wallet_name, wallet_dir);
696  if (!fs::is_regular_file(wallet_path)) {
697  wallet_path /= "wallet.dat";
698  }
699  if (createTutorial && fs::exists(wallet_path)) {
700  // some wallet already exists, don't create tutorial
701  createTutorial = false;
702  }
703  }
704  if (createTutorial) {
705  ret = app.createTutorialScreen();
706  }
707 #endif
708  if(!ret){
709  // wallet not loaded.
710  return 0;
711  }
712 
713  if (gArgs.GetBoolArg("-splash", true) && !gArgs.GetBoolArg("-min", false))
714  app.createSplashScreen(networkStyle.data());
715 
716  try {
717  app.createWindow(networkStyle.data());
718  app.requestInitialize();
719 #if defined(Q_OS_WIN)
720  WinShutdownMonitor::registerShutdownBlockReason(QObject::tr("%1 didn't yet exit safely...").arg(PACKAGE_NAME), (HWND)app.getMainWinId());
721 #endif
722  app.exec();
723  app.requestShutdown();
724  app.exec();
725  } catch (const std::exception& e) {
726  PrintExceptionContinue(&e, "Runaway exception");
727  app.handleRunawayException(QString::fromStdString(GetWarnings("gui")));
728  } catch (...) {
729  PrintExceptionContinue(nullptr, "Runaway exception");
730  app.handleRunawayException(QString::fromStdString(GetWarnings("gui")));
731  }
732  return app.getReturnValue();
733 }
734 #endif // BITCOIN_QT_TEST
int64_t CAmount
Amount in PIV (Can be negative)
Definition: amount.h:13
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
const CChainParams & Params()
Return the currently selected parameters.
void ReadConfigFile(const std::string &confPath)
Definition: system.cpp:832
void ParseParameters(int argc, const char *const argv[])
Definition: system.cpp:371
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
Definition: system.cpp:406
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
Definition: system.cpp:473
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition: system.cpp:425
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:449
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
Definition: system.cpp:481
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:465
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Definition: system.cpp:861
Main PIVX application object.
Definition: pivx.cpp:178
void requestedRestart(QStringList args)
void requestedInitialize()
ClientModel * clientModel
Definition: pivx.cpp:228
void splashFinished(QWidget *window)
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: pivx.cpp:379
void requestShutdown()
Request core shutdown.
Definition: pivx.cpp:448
QThread * coreThread
Definition: pivx.cpp:226
QTranslator qtTranslatorBase
Definition: pivx.cpp:238
QTimer * pollShutdownTimer
Definition: pivx.cpp:230
bool createTutorialScreen()
Create tutorial screen.
Definition: pivx.cpp:390
void startThread()
Definition: pivx.cpp:409
void createWindow(const NetworkStyle *networkStyle)
Create main window.
Definition: pivx.cpp:371
void parameterSetup()
parameter interaction/setup based on rules
Definition: pivx.cpp:431
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
Definition: pivx.cpp:537
QTranslator translatorBase
Definition: pivx.cpp:238
OptionsModel * optionsModel
Definition: pivx.cpp:227
PIVXGUI * window
Definition: pivx.cpp:229
int getReturnValue()
Get process return value.
Definition: pivx.cpp:206
void shutdownResult(int retval)
Definition: pivx.cpp:531
void updateTranslation(bool forceLangFromSettings=false)
Definition: pivx.cpp:404
QTranslator qtTranslator
Definition: pivx.cpp:238
void createOptionsModel()
Create options model.
Definition: pivx.cpp:366
void initializeResult(int retval)
Definition: pivx.cpp:475
void requestInitialize()
Request core initialization.
Definition: pivx.cpp:441
WId getMainWinId() const
Get window identifier of QMainWindow (PIVXGUI)
Definition: pivx.cpp:543
QTranslator translator
Definition: pivx.cpp:238
BitcoinApplication(int &argc, char **argv)
Definition: pivx.cpp:319
Class encapsulating PIVX Core startup and shutdown.
Definition: pivx.cpp:155
BitcoinCore()
Definition: pivx.cpp:245
void shutdownResult(int retval)
void initializeResult(int retval)
void runawayException(const QString &message)
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
Definition: pivx.cpp:249
void shutdown()
Definition: pivx.cpp:297
bool shutdownFromThread(const QString &type="Shutdown")
Definition: pivx.cpp:302
void restart(const QStringList &args)
Definition: pivx.cpp:280
void initialize()
Definition: pivx.cpp:255
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
Definition: guiinterface.h:87
static void callCleanup()
Definition: net.cpp:2367
boost::signals2::signal< std::string(const char *psz)> Translate
Translate a message to the native language of the user.
Definition: system.h:47
Model for PIVX network client.
Definition: clientmodel.h:50
Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text repre...
Definition: guiutil.h:156
"Help message" dialog box
Definition: utilitydialog.h:22
static bool pickDataDirectory()
Determine data directory.
Definition: intro.cpp:180
static const NetworkStyle * instantiate(const QString &networkId)
Get style associated with provided network id, or 0 if not known.
Interface from Qt to configuration data structure for PIVX client.
Definition: optionsmodel.h:22
bool resetSettings
Definition: optionsmodel.h:83
PIVX GUI main class.
Definition: pivxgui.h:46
void requestedRestart(QStringList args)
Restart handling.
void detectShutdown()
called by a timer to check if ShutdownRequested()
Definition: pivxgui.cpp:479
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
void message(const QString &title, const QString &message, unsigned int style, bool *ret=nullptr)
Notify the user of an event from the core network or transaction handling code.
Definition: pivxgui.cpp:381
static const QString DEFAULT_WALLET
Definition: pivxgui.h:50
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: pivxgui.cpp:246
static bool ipcSendCommandLine()
void message(const QString &title, const QString &message, unsigned int style)
static void ipcParseCommandLine(int argc, char *argv[])
void handleURIOrFile(const QString &s)
static void showShutdownWindow(QMainWindow *window)
Definition: splash.h:23
void slotFinish(QWidget *mainWin)
Slot to call finish() method as it's not defined as slot.
Definition: splash.cpp:66
Interface to PIVX wallet from Qt view code.
Definition: walletmodel.h:109
256-bit opaque blob.
Definition: uint256.h:138
char ** argv
Definition: fuzz.cpp:52
#define QAPP_ORG_NAME
Definition: guiconstants.h:52
#define QAPP_APP_NAME_DEFAULT
Definition: guiconstants.h:54
#define QAPP_ORG_DOMAIN
Definition: guiconstants.h:53
CClientUIInterface uiInterface
Definition: init.cpp:109
void InitParameterInteraction()
Parameter interaction: change current parameters depending on various rules.
Definition: init.cpp:856
bool AppInitMain()
Bitcoin core main initialization.
Definition: init.cpp:1168
bool AppInitParameterInteraction()
Initialization: parameter interaction.
Definition: init.cpp:974
bool AppInitBasicSetup()
Initialize PIVX core: Basic context setup.
Definition: init.cpp:805
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
Definition: init.cpp:1151
void InitLogging()
Initialize the logging infrastructure.
Definition: init.cpp:949
void Interrupt()
Interrupt threads.
Definition: init.cpp:186
void Shutdown()
Definition: init.cpp:199
#define LogPrint(category,...)
Definition: logging.h:163
@ QT
Definition: logging.h:56
Definition: uint256.h:212
#define PACKAGE_NAME
Definition: pivx-config.h:366
#define ENABLE_WALLET
Definition: pivx-config.h:42
int main(int argc, char *argv[])
Definition: pivx.cpp:552
Q_DECLARE_METATYPE(interfaces::WalletBalances)
void DebugMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
Definition: pivx.cpp:141
QSettings * settings
Definition: qtutils.cpp:197
UniValue help(const JSONRPCRequest &jsonRequest)
Definition: server.cpp:245
void StartShutdown()
Definition: shutdown.cpp:14
CTranslationInterface translationInterface
Definition: system.cpp:91
const char *const PIVX_CONF_FILENAME
Definition: system.cpp:81
bool CheckDataDirOption()
Definition: system.cpp:755
void ReleaseDirectoryLocks()
Release all directory locks.
Definition: system.cpp:134
ArgsManager gArgs
Definition: system.cpp:89
void SetupEnvironment()
Definition: system.cpp:1043
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
Definition: system.cpp:526
std::vector< CWalletRef > vpwallets
Definition: wallet.cpp:33
fs::path GetWalletDir()
Get the path of the wallet directory.
Definition: walletutil.cpp:8
OperationResult VerifyWalletPath(const std::string &walletFile)
Verify the wallet db's path.
Definition: walletutil.cpp:30
std::string GetWarnings(const std::string &strFor)
Definition: warnings.cpp:47