Bitcoin Core  27.99.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 #if defined(HAVE_CONFIG_H)
10 #endif
11 
12 #include <interfaces/node.h>
13 #include <qt/initexecutor.h>
14 
15 #include <assert.h>
16 #include <memory>
17 #include <optional>
18 
19 #include <QApplication>
20 
21 class BitcoinGUI;
22 class ClientModel;
23 class NetworkStyle;
24 class OptionsModel;
25 class PaymentServer;
26 class PlatformStyle;
27 class SplashScreen;
28 class WalletController;
29 class WalletModel;
30 namespace interfaces {
31 class Init;
32 } // namespace interfaces
33 
34 
36 class BitcoinApplication: public QApplication
37 {
38  Q_OBJECT
39 public:
40  explicit BitcoinApplication();
42 
43 #ifdef ENABLE_WALLET
45  void createPaymentServer();
46 #endif
48  void parameterSetup();
50  [[nodiscard]] bool createOptionsModel(bool resetSettings);
52  void InitPruneSetting(int64_t prune_MiB);
54  void createWindow(const NetworkStyle *networkStyle);
56  void createSplashScreen(const NetworkStyle *networkStyle);
60  bool baseInitialize();
61 
63  void requestInitialize();
64 
66  WId getMainWinId() const;
67 
69  void setupPlatformStyle();
70 
71  interfaces::Node& node() const { assert(m_node); return *m_node; }
72 
73 public Q_SLOTS:
74  void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
76  void requestShutdown();
78  void handleRunawayException(const QString &message);
79 
84  void handleNonFatalException(const QString& message);
85 
86 Q_SIGNALS:
90 
91 protected:
92  bool event(QEvent* e) override;
93 
94 private:
95  std::optional<InitExecutor> m_executor;
98  BitcoinGUI* window{nullptr};
99  QTimer* pollShutdownTimer{nullptr};
100 #ifdef ENABLE_WALLET
101  PaymentServer* paymentServer{nullptr};
102  WalletController* m_wallet_controller{nullptr};
103 #endif
104  const PlatformStyle* platformStyle{nullptr};
105  std::unique_ptr<QWidget> shutdownWindow;
106  SplashScreen* m_splash = nullptr;
107  std::unique_ptr<interfaces::Node> m_node;
108 
109  void startThread();
110 };
111 
112 int GuiMain(int argc, char* argv[]);
113 
114 #endif // BITCOIN_QT_BITCOIN_H
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:503
Main Bitcoin application object.
Definition: bitcoin.h:37
bool createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:262
std::optional< InitExecutor > m_executor
Definition: bitcoin.h:95
void requestedInitialize()
ClientModel * clientModel
Definition: bitcoin.h:97
void InitPruneSetting(int64_t prune_MiB)
Initialize prune setting.
Definition: bitcoin.cpp:341
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:297
void requestShutdown()
Request core shutdown.
Definition: bitcoin.cpp:353
SplashScreen * m_splash
Definition: bitcoin.h:106
void windowShown(BitcoinGUI *window)
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Definition: bitcoin.cpp:403
void createNode(interfaces::Init &init)
Create or spawn node.
Definition: bitcoin.cpp:304
QTimer * pollShutdownTimer
Definition: bitcoin.h:99
BitcoinGUI * window
Definition: bitcoin.h:98
const PlatformStyle * platformStyle
Definition: bitcoin.h:104
bool baseInitialize()
Basic initialization, before starting initialization/shutdown thread. Return true on success.
Definition: bitcoin.cpp:311
void createWindow(const NetworkStyle *networkStyle)
Create main window.
Definition: bitcoin.cpp:284
void parameterSetup()
parameter interaction/setup based on rules
Definition: bitcoin.cpp:331
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
Definition: bitcoin.cpp:456
OptionsModel * optionsModel
Definition: bitcoin.h:96
bool event(QEvent *e) override
Definition: bitcoin.cpp:483
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:232
std::unique_ptr< interfaces::Node > m_node
Definition: bitcoin.h:107
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:105
void requestInitialize()
Request core initialization.
Definition: bitcoin.cpp:346
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:475
void handleNonFatalException(const QString &message)
A helper function that shows a message box with details about a non-fatal exception.
Definition: bitcoin.cpp:465
interfaces::Node & node() const
Definition: bitcoin.h:71
Bitcoin GUI main class.
Definition: bitcoingui.h:70
Model for Bitcoin network client.
Definition: clientmodel.h:54
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:43
Class for the splashscreen with information of the running client.
Definition: splashscreen.h:27
Controller between interfaces::Node, WalletModel instances and the GUI.
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:48
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:30
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:70
Block and header tip information.
Definition: node.h:50
assert(!tx.IsCoinBase())