7#include <chainparams.h>
32#include <validation.h>
41#include <QLibraryInfo>
49#include <boost/signals2/connection.hpp>
53#if defined(QT_STATICPLUGIN)
55#if defined(QT_QPA_PLATFORM_XCB)
57#elif defined(QT_QPA_PLATFORM_WINDOWS)
59#elif defined(QT_QPA_PLATFORM_COCOA)
94 "interfaces::BlockAndHeaderTipInfo");
112 settings.value(
"language",
"").toString();
148 QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
155 QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
174 [](
const std::string &
error) {
return "- " +
error; });
184 std::vector<std::string>
errors;
193 QMessageBox::Reset | QMessageBox::Abort);
197 QObject::tr(
"Do you want to reset settings to default values, or "
198 "to abort without making changes?"));
201 messagebox.setDefaultButton(QMessageBox::Reset);
203 case QMessageBox::Reset:
205 case QMessageBox::Abort:
227 QObject::tr(
"A fatal error occurred. Check that settings file is "
228 "writable, or try running with -nosettings."));
245 LogPrintf(
"GUI: %s\n", msg.toStdString());
266 }
catch (
const std::exception &
e) {
279 }
catch (
const std::exception &
e) {
292 pollShutdownTimer(
nullptr), returnValue(0), platformStyle(
nullptr) {
328void BitcoinApplication::createPaymentServer() {
488 m_wallet_controller =
490 window->setWalletController(m_wallet_controller);
494 PaymentServer::LoadRootCAs();
520 &BitcoinGUI::handlePaymentRequest);
525 unsigned int style) {
541 QMessageBox::critical(
542 nullptr,
"Runaway exception",
543 BitcoinGUI::tr(
"A fatal error occurred. %1 can no longer continue "
544 "safely and will quit.")
546 QString(
"<br><br>") + message);
559#if defined(ENABLE_WALLET) && defined(ENABLE_BIP70)
561 "-allowselfsignedrootcertificates",
562 strprintf(
"Allow self signed root certificates (default: %d)",
566 argsman.AddArg(
"-choosedatadir",
567 strprintf(
"Choose data directory on startup (default: %d)",
572 "Set language, for example \"de_DE\" (default: system locale)",
577 "-rootcertificates=<file>",
578 "Set SSL root certificates for payment request (default: -system-)",
581 strprintf(
"Show splash screen on startup (default: %d)",
584 argsman.AddArg(
"-resetguisettings",
"Reset all settings changed in the GUI",
587 strprintf(
"Select platform to customize UI for (one of "
588 "windows, macosx, other; default: %s)",
596 common::WinCmdLineArgs
winArgs;
603 std::unique_ptr<interfaces::Node>
node =
623 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
624 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
639 QMessageBox::critical(
643 QString::fromStdString(
"Error parsing command line arguments: %1.")
644 .
arg(QString::fromStdString(
error)));
650 app.setupPlatformStyle();
675 app.installEventFilter(
693 Untranslated(
"Specified data directory \"%s\" does not exist.\n"),
695 QMessageBox::critical(
698 "Error: Specified data directory \"%1\" does not exist.")
705 QMessageBox::critical(
707 QObject::tr(
"Error: Cannot parse configuration file: %1.")
708 .
arg(QString::fromStdString(
error)));
724 }
catch (std::exception &
e) {
727 QObject::tr(
"Error: %1").
arg(
e.what()));
742 QApplication::setApplicationName(
networkStyle->getAppName());
765 app.createPaymentServer();
781 app.parameterSetup();
788 app.InitializePruneSetting(prune);
811 if (!
app.baseInitialize(config)) {
817 WinShutdownMonitor::registerShutdownBlockReason(
822 app.requestShutdown(config);
824 return app.getReturnValue();
825 }
catch (
const std::exception &
e) {
827 app.handleRunawayException(
828 QString::fromStdString(
app.node().getWarnings().translated));
831 app.handleRunawayException(
832 QString::fromStdString(
app.node().getWarnings().translated));
bool HelpRequested(const ArgsManager &args)
bool CheckDataDirOption(const ArgsManager &args)
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
const CChainParams & Params()
Return the currently selected parameters.
bool ReadSettingsFile(std::vector< std::string > *errors=nullptr)
Read settings file.
bool ParseParameters(int argc, const char *const argv[], std::string &error)
void EnsureDataDir() const
If datadir does not exist, create it along with wallets/ subdirectory(s).
bool GetSettingsPath(fs::path *filepath=nullptr, bool temp=false, bool backup=false) const
Get settings file path, or return false if read-write settings were disabled with -nosettings.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
bool WriteSettingsFile(std::vector< std::string > *errors=nullptr, bool backup=false) const
Write settings file or backup settings file.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
bool ReadConfigFiles(std::string &error, bool ignore_invalid_keys=false)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Class encapsulating Bitcoin ABC startup and shutdown.
interfaces::Node & m_node
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
void runawayException(const QString &message)
BitcoinABC(interfaces::Node &node)
void initialize(Config *config, RPCServer *rpcServer, HTTPRPCRequestProcessor *httpRPCRequestProcessor)
Main Bitcoin application object.
ClientModel * clientModel
bool baseInitialize(Config &config)
Basic initialization, before starting initialization/shutdown thread.
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
void windowShown(BitcoinGUI *window)
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
void setNode(interfaces::Node &node)
interfaces::Node & node() const
QTimer * pollShutdownTimer
void InitializePruneSetting(bool prune)
Initialize prune setting.
interfaces::Node * m_node
const PlatformStyle * platformStyle
void parameterSetup()
parameter interaction/setup based on rules
void handleRunawayException(const QString &message)
Handle runaway exceptions.
void createWindow(const Config *, const NetworkStyle *networkStyle)
Create main window.
OptionsModel * optionsModel
void createOptionsModel(bool resetSettings)
Create options model.
void requestInitialize(Config &config, RPCServer &rpcServer, HTTPRPCRequestProcessor &httpRPCRequestProcessor)
Request core initialization.
void setupPlatformStyle()
Setup platform style.
void requestedInitialize(Config *config, RPCServer *rpcServer, HTTPRPCRequestProcessor *httpRPCRequestProcessor)
std::unique_ptr< QWidget > shutdownWindow
void requestShutdown(Config &config)
Request core shutdown.
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
static const std::string DEFAULT_UIPLATFORM
void setClientModel(ClientModel *clientModel=nullptr, interfaces::BlockAndHeaderTipInfo *tip_info=nullptr)
Set the client model.
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
bool hasTrayIcon() const
Get the tray icon status.
void detectShutdown()
called by a timer to check if ShutdownRequested() has been set
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.
Model for Bitcoin network client.
OptionsModel * getOptionsModel()
Qt event filter that intercepts QEvent::FocusOut events for QLabel objects, and resets their ‘textInt...
Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text repre...
"Help message" dialog box
static bool showIfNeeded(bool &did_show_intro, bool &prune)
Determine data directory.
static const NetworkStyle * instantiate(const std::string &networkId)
Get style associated with provided BIP70 network id, or 0 if not known.
Interface from Qt to configuration data structure for Bitcoin client.
void SetPruneTargetGB(int prune_target_gb, bool force=false)
bool getMinimizeToTray() const
void setNode(interfaces::Node &node)
static bool ipcSendCommandLine()
void message(const QString &title, const QString &message, unsigned int style)
static void ipcParseCommandLine(int argc, char *argv[])
void receivedPaymentRequest(SendCoinsRecipient)
void handleURIOrFile(const QString &s)
Class for registering and managing all RPC calls.
static QWidget * showShutdownWindow(QMainWindow *window)
Class for the splashscreen with information of the running client.
void finish()
Hide the splash screen window and schedule the splash screen object for deletion.
void handleLoadWallet()
Handle wallet load notifications.
void setNode(interfaces::Node &node)
Controller between interfaces::Node, WalletModel instances and the GUI.
void coinsSent(interfaces::Wallet &wallet, SendCoinsRecipient recipient, QByteArray transaction)
static bool isWalletEnabled()
Top-level interface for a bitcoin node (bitcoind process).
virtual bilingual_str getWarnings()=0
Get warnings.
virtual void appShutdown()=0
Stop node.
virtual bool appInitMain(Config &config, RPCServer &rpcServer, HTTPRPCRequestProcessor &httpRPCRequestProcessor, interfaces::BlockAndHeaderTipInfo *tip_info=nullptr)=0
Start node.
virtual void startShutdown()=0
Start shutdown.
virtual bool baseInitialize(Config &config)=0
Initialize app dependencies.
const Config & GetConfig()
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
static constexpr int DEFAULT_PRUNE_TARGET_GB
static const int TOOLTIP_WRAP_THRESHOLD
static const bool DEFAULT_SPLASHSCREEN
#define QAPP_APP_NAME_DEFAULT
void InitLogging(const ArgsManager &args)
Initialize global loggers.
void SetupServerArgs(NodeContext &node)
Register all arguments with the ArgsManager.
void InitParameterInteraction(ArgsManager &args)
Parameter interaction: change current parameters depending on various rules.
static const bool DEFAULT_CHOOSE_DATADIR
bool error(const char *fmt, const Args &...args)
#define LogPrint(category,...)
void LogQtInfo()
Writes to debug.log short info about the used Qt and the host system.
std::unique_ptr< Node > MakeNode(node::NodeContext *context)
Return implementation of Node interface.
void ThreadSetInternalName(std::string &&)
Set the internal (in-memory) name of the current thread only.
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
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.
void noui_InitMessage(const std::string &message)
Non-GUI handler, which only logs a message.
bool noui_ThreadSafeMessageBox(const bilingual_str &message, const std::string &caption, unsigned int style)
Non-GUI handler, which logs and prints messages.
static const bool DEFAULT_SELFSIGNED_ROOTCERTS
static void RegisterMetaTypes()
static QString GetLangTerritory()
int GuiMain(int argc, char *argv[])
static void SetupUIArgs(ArgsManager &argsman)
static bool InitSettings()
static const char * qt_argv
static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator)
Set up translations.
void DebugMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
static std::string JoinErrors(const std::vector< std::string > &errors)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
Block and header tip information.
NodeContext struct containing references to chain state and connection state.
bilingual_str _(const char *psz)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
CClientUIInterface uiInterface
bool InitError(const bilingual_str &str)
Show error message.
SynchronizationState
Current sync state passed to tip changed callbacks.