Bitcoin Core  22.0.0
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:
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 InitPruneSetting(int64_t prune_MiB);
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; }
95 
96 public Q_SLOTS:
97  void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
98  void shutdownResult();
100  void handleRunawayException(const QString &message);
101 
106  void handleNonFatalException(const QString& message);
107 
108 Q_SIGNALS:
109  void requestedInitialize();
110  void requestedShutdown();
111  void splashFinished();
113 
114 private:
115  QThread *coreThread;
120 #ifdef ENABLE_WALLET
121  PaymentServer* paymentServer{nullptr};
122  WalletController* m_wallet_controller{nullptr};
123 #endif
126  std::unique_ptr<QWidget> shutdownWindow;
127  SplashScreen* m_splash = nullptr;
129 
130  void startThread();
131 };
132 
133 int GuiMain(int argc, char* argv[]);
134 
135 #endif // BITCOIN_QT_BITCOIN_H
OptionsModel * optionsModel
Definition: bitcoin.h:116
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:218
assert(!tx.IsCoinBase())
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 parameterSetup()
parameter interaction/setup based on rules
Definition: bitcoin.cpp:312
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
Definition: bitcoin.cpp:163
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
Definition: bitcoin.cpp:418
void requestInitialize()
Request core initialization.
Definition: bitcoin.cpp:327
Controller between interfaces::Node, WalletModel instances and the GUI.
Bitcoin GUI main class.
Definition: bitcoingui.h:68
interfaces::Node & m_node
Definition: bitcoin.h:51
void createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:254
void handleNonFatalException(const QString &message)
A helper function that shows a message box with details about a non-fatal exception.
Definition: bitcoin.cpp:427
void requestedInitialize()
interfaces::Node & node() const
Definition: bitcoin.h:93
void setNode(interfaces::Node &node)
Definition: bitcoin.cpp:279
void InitPruneSetting(int64_t prune_MiB)
Initialize prune setting.
Definition: bitcoin.cpp:322
void shutdown()
Definition: bitcoin.cpp:185
BitcoinCore(interfaces::Node &node)
Definition: bitcoin.cpp:158
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:267
Main Bitcoin application object.
Definition: bitcoin.h:55
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
SplashScreen * m_splash
Definition: bitcoin.h:127
Block and header tip information.
Definition: node.h:44
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:126
void initialize()
Definition: bitcoin.cpp:169
void windowShown(BitcoinGUI *window)
Model for Bitcoin network client.
Definition: clientmodel.h:47
void shutdownResult()
Definition: bitcoin.cpp:413
BitcoinGUI * window
Definition: bitcoin.h:118
void requestShutdown()
Request core shutdown.
Definition: bitcoin.cpp:334
QThread * coreThread
Definition: bitcoin.h:115
void createWindow(const NetworkStyle *networkStyle)
Create main window.
Definition: bitcoin.cpp:259
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
interfaces::Node * m_node
Definition: bitcoin.h:128
void shutdownResult()
void runawayException(const QString &message)
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:437
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:54
bool baseInitialize()
Basic initialization, before starting initialization/shutdown thread. Return true on success...
Definition: bitcoin.cpp:287
ClientModel * clientModel
Definition: bitcoin.h:117
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Definition: bitcoin.cpp:362
int getReturnValue() const
Get process return value.
Definition: bitcoin.h:85
QTimer * pollShutdownTimer
Definition: bitcoin.h:119
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:455
const PlatformStyle * platformStyle
Definition: bitcoin.h:125