Bitcoin ABC  0.26.3
P2P Digital Currency
bitcoin.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 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)
9 #include <config/bitcoin-config.h>
10 #endif
11 
12 #include <QApplication>
13 
14 #include <cassert>
15 #include <memory>
16 
17 #include <interfaces/node.h>
18 
19 class BitcoinGUI;
20 class ClientModel;
21 class Config;
23 class NetworkStyle;
24 class OptionsModel;
25 class PaymentServer;
26 class PlatformStyle;
27 class RPCServer;
28 class SplashScreen;
29 class WalletController;
30 class WalletModel;
31 
36 class BitcoinABC : public QObject {
37  Q_OBJECT
38 public:
39  explicit BitcoinABC(interfaces::Node &node);
40 
41 public Q_SLOTS:
42  void initialize(Config *config, RPCServer *rpcServer,
43  HTTPRPCRequestProcessor *httpRPCRequestProcessor);
44  void shutdown();
45 
46 Q_SIGNALS:
47  void initializeResult(bool success,
50  void runawayException(const QString &message);
51 
52 private:
54  void handleRunawayException(const std::exception *e);
55 
57 };
58 
60 class BitcoinApplication : public QApplication {
61  Q_OBJECT
62 public:
63  explicit BitcoinApplication();
65 
66 #ifdef ENABLE_WALLET
68  void createPaymentServer();
69 #endif
71  void parameterSetup();
73  void createOptionsModel(bool resetSettings);
75  void InitializePruneSetting(bool prune);
77  void createWindow(const Config *, const NetworkStyle *networkStyle);
79  void createSplashScreen(const NetworkStyle *networkStyle);
82  bool baseInitialize(Config &config);
83 
85  void requestInitialize(Config &config, RPCServer &rpcServer,
86  HTTPRPCRequestProcessor &httpRPCRequestProcessor);
88  void requestShutdown(Config &config);
89 
91  int getReturnValue() const { return returnValue; }
92 
94  WId getMainWinId() const;
95 
97  void setupPlatformStyle();
98 
100  assert(m_node);
101  return *m_node;
102  }
104 
105 public Q_SLOTS:
106  void initializeResult(bool success,
108  void shutdownResult();
111  void handleRunawayException(const QString &message);
112 
113 Q_SIGNALS:
114  void requestedInitialize(Config *config, RPCServer *rpcServer,
115  HTTPRPCRequestProcessor *httpRPCRequestProcessor);
119 
120 private:
121  QThread *coreThread;
126 #ifdef ENABLE_WALLET
127  PaymentServer *paymentServer{nullptr};
128  WalletController *m_wallet_controller{nullptr};
129 #endif
132  std::unique_ptr<QWidget> shutdownWindow;
133  SplashScreen *m_splash = nullptr;
135 
136  void startThread();
137 };
138 
139 int GuiMain(int argc, char *argv[]);
140 
141 #endif // BITCOIN_QT_BITCOIN_H
Class encapsulating Bitcoin ABC startup and shutdown.
Definition: bitcoin.h:36
interfaces::Node & m_node
Definition: bitcoin.h:56
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
Definition: bitcoin.cpp:182
void shutdown()
Definition: bitcoin.cpp:204
void runawayException(const QString &message)
void shutdownResult()
BitcoinABC(interfaces::Node &node)
Definition: bitcoin.cpp:180
void initialize(Config *config, RPCServer *rpcServer, HTTPRPCRequestProcessor *httpRPCRequestProcessor)
Definition: bitcoin.cpp:188
Main Bitcoin application object.
Definition: bitcoin.h:60
ClientModel * clientModel
Definition: bitcoin.h:123
bool baseInitialize(Config &config)
Basic initialization, before starting initialization/shutdown thread.
Definition: bitcoin.cpp:304
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:278
SplashScreen * m_splash
Definition: bitcoin.h:133
void windowShown(BitcoinGUI *window)
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Definition: bitcoin.cpp:401
QThread * coreThread
Definition: bitcoin.h:121
void setNode(interfaces::Node &node)
Definition: bitcoin.cpp:293
QTimer * pollShutdownTimer
Definition: bitcoin.h:125
BitcoinGUI * window
Definition: bitcoin.h:124
void InitializePruneSetting(bool prune)
Initialize prune setting.
Definition: bitcoin.cpp:357
interfaces::Node * m_node
Definition: bitcoin.h:134
const PlatformStyle * platformStyle
Definition: bitcoin.h:131
int getReturnValue() const
Get process return value.
Definition: bitcoin.h:91
void parameterSetup()
parameter interaction/setup based on rules
Definition: bitcoin.cpp:348
void handleRunawayException(const QString &message)
Handle runaway exceptions.
Definition: bitcoin.cpp:471
void createWindow(const Config *, const NetworkStyle *networkStyle)
Create main window.
Definition: bitcoin.cpp:268
OptionsModel * optionsModel
Definition: bitcoin.h:122
void createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:264
void requestInitialize(Config &config, RPCServer &rpcServer, HTTPRPCRequestProcessor &httpRPCRequestProcessor)
Request core initialization.
Definition: bitcoin.cpp:363
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:229
void requestedInitialize(Config *config, RPCServer *rpcServer, HTTPRPCRequestProcessor *httpRPCRequestProcessor)
void shutdownResult()
Definition: bitcoin.cpp:466
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:132
void requestShutdown(Config &config)
Request core shutdown.
Definition: bitcoin.cpp:374
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:481
interfaces::Node & node() const
Definition: bitcoin.h:99
Bitcoin GUI main class.
Definition: bitcoingui.h:68
Model for Bitcoin network client.
Definition: clientmodel.h:36
Definition: config.h:17
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:48
Class for registering and managing all RPC calls.
Definition: server.h:39
Class for the splashscreen with information of the running client.
Definition: splashscreen.h:26
Controller between interfaces::Node, WalletModel instances and the GUI.
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:57
Definition: init.h:28
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:562
Block and header tip information.
Definition: node.h:48
assert(!tx.IsCoinBase())