Bitcoin Core  29.1.0
P2P Digital Currency
bitcoin.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2022 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 #ifndef BITCOIN_QT_BITCOIN_H
6 #define BITCOIN_QT_BITCOIN_H
7 
8 #include <bitcoin-build-config.h> // IWYU pragma: keep
9 
10 #include <interfaces/node.h>
11 #include <qt/initexecutor.h>
12 
13 #include <assert.h>
14 #include <memory>
15 #include <optional>
16 
17 #include <QApplication>
18 
19 class BitcoinGUI;
20 class ClientModel;
21 class NetworkStyle;
22 class OptionsModel;
23 class PaymentServer;
24 class PlatformStyle;
25 class SplashScreen;
26 class WalletController;
27 class WalletModel;
28 namespace interfaces {
29 class Init;
30 } // namespace interfaces
31 
32 
34 class BitcoinApplication: public QApplication
35 {
36  Q_OBJECT
37 public:
38  explicit BitcoinApplication();
40 
41 #ifdef ENABLE_WALLET
42  void createPaymentServer();
44 #endif
45  void parameterSetup();
48  [[nodiscard]] bool createOptionsModel(bool resetSettings);
50  void InitPruneSetting(int64_t prune_MiB);
52  void createWindow(const NetworkStyle *networkStyle);
54  void createSplashScreen(const NetworkStyle *networkStyle);
58  bool baseInitialize();
59 
61  void requestInitialize();
62 
64  WId getMainWinId() const;
65 
67  void setupPlatformStyle();
68 
69  interfaces::Node& node() const { assert(m_node); return *m_node; }
70 
71 public Q_SLOTS:
72  void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
74  void requestShutdown();
76  void handleRunawayException(const QString &message);
77 
82  void handleNonFatalException(const QString& message);
83 
84 Q_SIGNALS:
85  void requestedInitialize();
86  void requestedShutdown();
88 
89 protected:
90  bool event(QEvent* e) override;
91 
92 private:
93  std::optional<InitExecutor> m_executor;
96  BitcoinGUI* window{nullptr};
97  QTimer* pollShutdownTimer{nullptr};
98 #ifdef ENABLE_WALLET
99  PaymentServer* paymentServer{nullptr};
100  WalletController* m_wallet_controller{nullptr};
101 #endif
102  const PlatformStyle* platformStyle{nullptr};
103  std::unique_ptr<QWidget> shutdownWindow;
104  SplashScreen* m_splash = nullptr;
105  std::unique_ptr<interfaces::Node> m_node;
106 
107  void startThread();
108 };
109 
110 int GuiMain(int argc, char* argv[]);
111 
112 #endif // BITCOIN_QT_BITCOIN_H
OptionsModel * optionsModel
Definition: bitcoin.h:94
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:217
assert(!tx.IsCoinBase())
Class for the splashscreen with information of the running client.
Definition: splashscreen.h:26
void parameterSetup()
parameter interaction/setup based on rules
Definition: bitcoin.cpp:316
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
Definition: bitcoin.cpp:441
void requestInitialize()
Request core initialization.
Definition: bitcoin.cpp:331
Controller between interfaces::Node, WalletModel instances and the GUI.
Bitcoin GUI main class.
Definition: bitcoingui.h:67
std::unique_ptr< interfaces::Node > m_node
Definition: bitcoin.h:105
void handleNonFatalException(const QString &message)
A helper function that shows a message box with details about a non-fatal exception.
Definition: bitcoin.cpp:450
void requestedInitialize()
interfaces::Node & node() const
Definition: bitcoin.h:69
void InitPruneSetting(int64_t prune_MiB)
Initialize prune setting.
Definition: bitcoin.cpp:326
void createNode(interfaces::Init &init)
Create or spawn node.
Definition: bitcoin.cpp:289
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:282
Main Bitcoin application object.
Definition: bitcoin.h:34
SplashScreen * m_splash
Definition: bitcoin.h:104
Block and header tip information.
Definition: node.h:50
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:103
void windowShown(BitcoinGUI *window)
Model for Bitcoin network client.
Definition: clientmodel.h:56
bool createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:247
BitcoinGUI * window
Definition: bitcoin.h:96
void requestShutdown()
Request core shutdown.
Definition: bitcoin.cpp:338
void createWindow(const NetworkStyle *networkStyle)
Create main window.
Definition: bitcoin.cpp:269
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:42
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:30
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:460
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:70
bool baseInitialize()
Basic initialization, before starting initialization/shutdown thread. Return true on success...
Definition: bitcoin.cpp:296
bool event(QEvent *e) override
Definition: bitcoin.cpp:468
ClientModel * clientModel
Definition: bitcoin.h:95
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Definition: bitcoin.cpp:388
std::optional< InitExecutor > m_executor
Definition: bitcoin.h:93
QTimer * pollShutdownTimer
Definition: bitcoin.h:97
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:488
const PlatformStyle * platformStyle
Definition: bitcoin.h:102