Bitcoin Core  22.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 <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
44  void createPaymentServer();
46 #endif
47  void parameterSetup();
50  void 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();
65  void requestShutdown();
66 
68  int getReturnValue() const { return returnValue; }
69 
71  WId getMainWinId() const;
72 
74  void setupPlatformStyle();
75 
76  interfaces::Node& node() const { assert(m_node); return *m_node; }
77 
78 public Q_SLOTS:
79  void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
80  void shutdownResult();
82  void handleRunawayException(const QString &message);
83 
88  void handleNonFatalException(const QString& message);
89 
90 Q_SIGNALS:
91  void requestedInitialize();
92  void requestedShutdown();
93  void splashFinished();
95 
96 private:
97  std::optional<InitExecutor> m_executor;
102 #ifdef ENABLE_WALLET
103  PaymentServer* paymentServer{nullptr};
104  WalletController* m_wallet_controller{nullptr};
105 #endif
108  std::unique_ptr<QWidget> shutdownWindow;
109  SplashScreen* m_splash = nullptr;
110  std::unique_ptr<interfaces::Node> m_node;
111 
112  void startThread();
113 };
114 
115 int GuiMain(int argc, char* argv[]);
116 
117 #endif // BITCOIN_QT_BITCOIN_H
interfaces
Definition: dummywallet.cpp:11
BitcoinApplication::setupPlatformStyle
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:224
BitcoinApplication::createSplashScreen
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:267
assert
assert(!tx.IsCoinBase())
BitcoinApplication::splashFinished
void splashFinished()
BitcoinApplication::platformStyle
const PlatformStyle * platformStyle
Definition: bitcoin.h:107
BitcoinApplication::node
interfaces::Node & node() const
Definition: bitcoin.h:76
BitcoinApplication::~BitcoinApplication
~BitcoinApplication()
Definition: bitcoin.cpp:237
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
BitcoinApplication::handleRunawayException
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
Definition: bitcoin.cpp:421
BitcoinApplication::pollShutdownTimer
QTimer * pollShutdownTimer
Definition: bitcoin.h:101
BitcoinApplication::m_executor
std::optional< InitExecutor > m_executor
Definition: bitcoin.h:97
interfaces::Init
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:26
BitcoinApplication::optionsModel
OptionsModel * optionsModel
Definition: bitcoin.h:98
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:68
bitcoin-config.h
BitcoinApplication::requestedShutdown
void requestedShutdown()
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
node.h
BitcoinApplication::requestInitialize
void requestInitialize()
Request core initialization.
Definition: bitcoin.cpp:320
WalletController
Controller between interfaces::Node, WalletModel instances and the GUI.
Definition: walletcontroller.h:45
BitcoinApplication::returnValue
int returnValue
Definition: bitcoin.h:106
BitcoinApplication::createNode
void createNode(interfaces::Init &init)
Create or spawn node.
Definition: bitcoin.cpp:279
BitcoinApplication::createOptionsModel
void createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:254
BitcoinApplication::shutdownWindow
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:108
interfaces::Node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:54
BitcoinApplication::window
BitcoinGUI * window
Definition: bitcoin.h:100
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:210
BitcoinApplication::startThread
void startThread()
Definition: bitcoin.cpp:292
BitcoinApplication::requestShutdown
void requestShutdown()
Request core shutdown.
Definition: bitcoin.cpp:327
init
Definition: bitcoin-node.cpp:16
BitcoinApplication::m_splash
SplashScreen * m_splash
Definition: bitcoin.h:109
initexecutor.h
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:365
BitcoinApplication::getMainWinId
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:440
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:430
BitcoinApplication::windowShown
void windowShown(BitcoinGUI *window)
BitcoinApplication::InitPruneSetting
void InitPruneSetting(int64_t prune_MiB)
Initialize prune setting.
Definition: bitcoin.cpp:315
PlatformStyle
Definition: platformstyle.h:13
BitcoinGUI
Bitcoin GUI main class.
Definition: bitcoingui.h:68
BitcoinApplication::m_node
std::unique_ptr< interfaces::Node > m_node
Definition: bitcoin.h:110
BitcoinApplication::parameterSetup
void parameterSetup()
parameter interaction/setup based on rules
Definition: bitcoin.cpp:305
BitcoinApplication
Main Bitcoin application object.
Definition: bitcoin.h:36
BitcoinApplication::shutdownResult
void shutdownResult()
Definition: bitcoin.cpp:416
GuiMain
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:458
BitcoinApplication::clientModel
ClientModel * clientModel
Definition: bitcoin.h:99