Bitcoin Core  0.20.99
P2P Digital Currency
bitcoin.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2020 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 <QApplication>
13 #include <assert.h>
14 #include <memory>
15 
16 #include <interfaces/node.h>
17 
18 class BitcoinGUI;
19 class ClientModel;
20 class NetworkStyle;
21 class OptionsModel;
22 class PaymentServer;
23 class PlatformStyle;
24 class SplashScreen;
25 class WalletController;
26 class WalletModel;
27 
28 
32 class BitcoinCore: public QObject
33 {
34  Q_OBJECT
35 public:
36  explicit BitcoinCore(interfaces::Node& node);
37 
38 public Q_SLOTS:
39  void initialize();
40  void shutdown();
41 
42 Q_SIGNALS:
43  void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
44  void shutdownResult();
45  void runawayException(const QString &message);
46 
47 private:
49  void handleRunawayException(const std::exception *e);
50 
52 };
53 
55 class BitcoinApplication: public QApplication
56 {
57  Q_OBJECT
58 public:
59  explicit BitcoinApplication();
61 
62 #ifdef ENABLE_WALLET
63  void createPaymentServer();
65 #endif
66  void parameterSetup();
69  void createOptionsModel(bool resetSettings);
71  void InitializePruneSetting(bool prune);
73  void createWindow(const NetworkStyle *networkStyle);
75  void createSplashScreen(const NetworkStyle *networkStyle);
77  bool baseInitialize();
78 
80  void requestInitialize();
82  void requestShutdown();
83 
85  int getReturnValue() const { return returnValue; }
86 
88  WId getMainWinId() const;
89 
91  void setupPlatformStyle();
92 
93  interfaces::Node& node() const { assert(m_node); return *m_node; }
94  void setNode(interfaces::Node& node);
95 
96 public Q_SLOTS:
97  void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
98  void shutdownResult();
100  void handleRunawayException(const QString &message);
101 
102 Q_SIGNALS:
103  void requestedInitialize();
104  void requestedShutdown();
105  void splashFinished();
106  void windowShown(BitcoinGUI* window);
107 
108 private:
109  QThread *coreThread;
114 #ifdef ENABLE_WALLET
115  PaymentServer* paymentServer{nullptr};
116  WalletController* m_wallet_controller{nullptr};
117 #endif
120  std::unique_ptr<QWidget> shutdownWindow;
121  SplashScreen* m_splash = nullptr;
123 
124  void startThread();
125 };
126 
127 int GuiMain(int argc, char* argv[]);
128 
129 #endif // BITCOIN_QT_BITCOIN_H
OptionsModel * optionsModel
Definition: bitcoin.h:110
Class for the splashscreen with information of the running client.
Definition: splashscreen.h:26
Class encapsulating Bitcoin Core startup and shutdown.
Definition: bitcoin.h:32
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
Definition: bitcoin.cpp:159
Controller between interfaces::Node, WalletModel instances and the GUI.
Bitcoin GUI main class.
Definition: bitcoingui.h:66
interfaces::Node & m_node
Definition: bitcoin.h:51
interfaces::Node & node() const
Definition: bitcoin.h:93
void shutdown()
Definition: bitcoin.cpp:181
BitcoinCore(interfaces::Node &node)
Definition: bitcoin.cpp:154
Main Bitcoin application object.
Definition: bitcoin.h:55
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Block and header tip information.
Definition: node.h:42
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:120
void initialize()
Definition: bitcoin.cpp:165
Model for Bitcoin network client.
Definition: clientmodel.h:46
BitcoinGUI * window
Definition: bitcoin.h:112
QThread * coreThread
Definition: bitcoin.h:109
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:39
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
void shutdownResult()
void runawayException(const QString &message)
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:52
ClientModel * clientModel
Definition: bitcoin.h:111
int getReturnValue() const
Get process return value.
Definition: bitcoin.h:85
QTimer * pollShutdownTimer
Definition: bitcoin.h:113
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:440
const PlatformStyle * platformStyle
Definition: bitcoin.h:119