Bitcoin Core  21.99.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
BitcoinCore::handleRunawayException
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
Definition: bitcoin.cpp:163
BitcoinApplication::setupPlatformStyle
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:218
BitcoinApplication::createSplashScreen
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:267
BitcoinCore::runawayException
void runawayException(const QString &message)
BitcoinApplication::setNode
void setNode(interfaces::Node &node)
Definition: bitcoin.cpp:279
assert
assert(!tx.IsCoinBase())
BitcoinApplication::splashFinished
void splashFinished()
BitcoinApplication::platformStyle
const PlatformStyle * platformStyle
Definition: bitcoin.h:125
BitcoinApplication::node
interfaces::Node & node() const
Definition: bitcoin.h:93
BitcoinApplication::~BitcoinApplication
~BitcoinApplication()
Definition: bitcoin.cpp:231
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
BitcoinCore::initializeResult
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
BitcoinApplication::handleRunawayException
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
Definition: bitcoin.cpp:418
BitcoinApplication::pollShutdownTimer
QTimer * pollShutdownTimer
Definition: bitcoin.h:119
BitcoinApplication::optionsModel
OptionsModel * optionsModel
Definition: bitcoin.h:116
NetworkStyle
Definition: networkstyle.h:13
BitcoinApplication::requestedInitialize
void requestedInitialize()
interfaces::BlockAndHeaderTipInfo
Block and header tip information.
Definition: node.h:44
BitcoinApplication::getReturnValue
int getReturnValue() const
Get process return value.
Definition: bitcoin.h:85
bitcoin-config.h
BitcoinApplication::requestedShutdown
void requestedShutdown()
BitcoinApplication::m_node
interfaces::Node * m_node
Definition: bitcoin.h:128
OptionsModel
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:39
PaymentServer
Definition: paymentserver.h:57
BitcoinApplication::createWindow
void createWindow(const NetworkStyle *networkStyle)
Create main window.
Definition: bitcoin.cpp:259
BitcoinCore::shutdown
void shutdown()
Definition: bitcoin.cpp:185
node.h
BitcoinApplication::requestInitialize
void requestInitialize()
Request core initialization.
Definition: bitcoin.cpp:327
WalletController
Controller between interfaces::Node, WalletModel instances and the GUI.
Definition: walletcontroller.h:45
BitcoinCore::shutdownResult
void shutdownResult()
BitcoinApplication::returnValue
int returnValue
Definition: bitcoin.h:124
BitcoinCore::BitcoinCore
BitcoinCore(interfaces::Node &node)
Definition: bitcoin.cpp:158
BitcoinApplication::createOptionsModel
void createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:254
BitcoinCore::initialize
void initialize()
Definition: bitcoin.cpp:169
BitcoinApplication::coreThread
QThread * coreThread
Definition: bitcoin.h:115
BitcoinApplication::shutdownWindow
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:126
interfaces::Node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:54
BitcoinApplication::window
BitcoinGUI * window
Definition: bitcoin.h:118
BitcoinCore
Class encapsulating Bitcoin Core startup and shutdown.
Definition: bitcoin.h:32
ClientModel
Model for Bitcoin network client.
Definition: clientmodel.h:47
SplashScreen
Class for the splashscreen with information of the running client.
Definition: splashscreen.h:26
BitcoinApplication::BitcoinApplication
BitcoinApplication()
Definition: bitcoin.cpp:203
BitcoinApplication::startThread
void startThread()
Definition: bitcoin.cpp:292
BitcoinApplication::requestShutdown
void requestShutdown()
Request core shutdown.
Definition: bitcoin.cpp:334
BitcoinApplication::m_splash
SplashScreen * m_splash
Definition: bitcoin.h:127
BitcoinApplication::baseInitialize
bool baseInitialize()
Basic initialization, before starting initialization/shutdown thread. Return true on success.
Definition: bitcoin.cpp:287
BitcoinApplication::initializeResult
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Definition: bitcoin.cpp:362
node
Definition: interfaces.cpp:66
BitcoinApplication::getMainWinId
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:437
BitcoinApplication::handleNonFatalException
void handleNonFatalException(const QString &message)
A helper function that shows a message box with details about a non-fatal exception.
Definition: bitcoin.cpp:427
BitcoinApplication::windowShown
void windowShown(BitcoinGUI *window)
BitcoinApplication::InitPruneSetting
void InitPruneSetting(int64_t prune_MiB)
Initialize prune setting.
Definition: bitcoin.cpp:322
PlatformStyle
Definition: platformstyle.h:13
BitcoinGUI
Bitcoin GUI main class.
Definition: bitcoingui.h:68
BitcoinApplication::parameterSetup
void parameterSetup()
parameter interaction/setup based on rules
Definition: bitcoin.cpp:312
BitcoinApplication
Main Bitcoin application object.
Definition: bitcoin.h:55
BitcoinApplication::shutdownResult
void shutdownResult()
Definition: bitcoin.cpp:413
GuiMain
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:455
BitcoinCore::m_node
interfaces::Node & m_node
Definition: bitcoin.h:51
BitcoinApplication::clientModel
ClientModel * clientModel
Definition: bitcoin.h:117