Bitcoin Core  24.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  int getReturnValue() const { return returnValue; }
67 
69  WId getMainWinId() const;
70 
72  void setupPlatformStyle();
73 
74  interfaces::Node& node() const { assert(m_node); return *m_node; }
75 
76 public Q_SLOTS:
77  void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
79  void requestShutdown();
81  void handleRunawayException(const QString &message);
82 
87  void handleNonFatalException(const QString& message);
88 
89 Q_SIGNALS:
93 
94 protected:
95  bool event(QEvent* e) override;
96 
97 private:
98  std::optional<InitExecutor> m_executor;
101  BitcoinGUI* window{nullptr};
102  QTimer* pollShutdownTimer{nullptr};
103 #ifdef ENABLE_WALLET
104  PaymentServer* paymentServer{nullptr};
105  WalletController* m_wallet_controller{nullptr};
106 #endif
107  int returnValue{0};
108  const PlatformStyle* platformStyle{nullptr};
109  std::unique_ptr<QWidget> shutdownWindow;
110  SplashScreen* m_splash = nullptr;
111  std::unique_ptr<interfaces::Node> m_node;
112 
113  void startThread();
114 };
115 
116 int GuiMain(int argc, char* argv[]);
117 
118 #endif // BITCOIN_QT_BITCOIN_H
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:504
Main Bitcoin application object.
Definition: bitcoin.h:37
bool createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:269
std::optional< InitExecutor > m_executor
Definition: bitcoin.h:98
void requestedInitialize()
ClientModel * clientModel
Definition: bitcoin.h:100
void InitPruneSetting(int64_t prune_MiB)
Initialize prune setting.
Definition: bitcoin.cpp:348
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:304
void requestShutdown()
Request core shutdown.
Definition: bitcoin.cpp:360
SplashScreen * m_splash
Definition: bitcoin.h:110
void windowShown(BitcoinGUI *window)
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Definition: bitcoin.cpp:405
void createNode(interfaces::Init &init)
Create or spawn node.
Definition: bitcoin.cpp:311
QTimer * pollShutdownTimer
Definition: bitcoin.h:102
BitcoinGUI * window
Definition: bitcoin.h:101
const PlatformStyle * platformStyle
Definition: bitcoin.h:108
bool baseInitialize()
Basic initialization, before starting initialization/shutdown thread. Return true on success.
Definition: bitcoin.cpp:318
int getReturnValue() const
Get process return value.
Definition: bitcoin.h:66
void createWindow(const NetworkStyle *networkStyle)
Create main window.
Definition: bitcoin.cpp:291
void parameterSetup()
parameter interaction/setup based on rules
Definition: bitcoin.cpp:338
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
Definition: bitcoin.cpp:457
OptionsModel * optionsModel
Definition: bitcoin.h:99
bool event(QEvent *e) override
Definition: bitcoin.cpp:484
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:239
std::unique_ptr< interfaces::Node > m_node
Definition: bitcoin.h:111
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:109
void requestInitialize()
Request core initialization.
Definition: bitcoin.cpp:353
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:476
void handleNonFatalException(const QString &message)
A helper function that shows a message box with details about a non-fatal exception.
Definition: bitcoin.cpp:466
interfaces::Node & node() const
Definition: bitcoin.h:74
Bitcoin GUI main class.
Definition: bitcoingui.h:70
Model for Bitcoin network client.
Definition: clientmodel.h:55
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:41
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:53
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())