Bitcoin ABC  0.24.7
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,
49  void shutdownResult();
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
67  void createPaymentServer();
69 #endif
70  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);
116  void requestedShutdown();
117  void splashFinished();
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
BitcoinApplication::setupPlatformStyle
void setupPlatformStyle()
Setup platform style.
Definition: bitcoin.cpp:226
BitcoinApplication::createSplashScreen
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
Definition: bitcoin.cpp:275
BitcoinApplication::setNode
void setNode(interfaces::Node &node)
Definition: bitcoin.cpp:290
BitcoinApplication::splashFinished
void splashFinished()
BitcoinApplication::platformStyle
const PlatformStyle * platformStyle
Definition: bitcoin.h:131
BitcoinApplication::node
interfaces::Node & node() const
Definition: bitcoin.h:99
BitcoinApplication::~BitcoinApplication
~BitcoinApplication()
Definition: bitcoin.cpp:241
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
BitcoinABC::initializeResult
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
BitcoinApplication::handleRunawayException
void handleRunawayException(const QString &message)
Handle runaway exceptions.
Definition: bitcoin.cpp:468
BitcoinApplication::pollShutdownTimer
QTimer * pollShutdownTimer
Definition: bitcoin.h:125
BitcoinABC::BitcoinABC
BitcoinABC(interfaces::Node &node)
Definition: bitcoin.cpp:177
node.h
BitcoinApplication::optionsModel
OptionsModel * optionsModel
Definition: bitcoin.h:122
HTTPRPCRequestProcessor
Definition: httprpc.h:17
NetworkStyle
Definition: networkstyle.h:13
interfaces::BlockAndHeaderTipInfo
Block and header tip information.
Definition: node.h:46
BitcoinApplication::getReturnValue
int getReturnValue() const
Get process return value.
Definition: bitcoin.h:91
BitcoinABC::shutdownResult
void shutdownResult()
RPCServer
Class for registering and managing all RPC calls.
Definition: server.h:40
BitcoinApplication::requestInitialize
void requestInitialize(Config &config, RPCServer &rpcServer, HTTPRPCRequestProcessor &httpRPCRequestProcessor)
Request core initialization.
Definition: bitcoin.cpp:360
BitcoinApplication::requestedShutdown
void requestedShutdown()
Config
Definition: config.h:17
BitcoinApplication::m_node
interfaces::Node * m_node
Definition: bitcoin.h:134
OptionsModel
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:49
PaymentServer
Definition: paymentserver.h:63
BitcoinABC
Class encapsulating Bitcoin ABC startup and shutdown.
Definition: bitcoin.h:36
GuiMain
int GuiMain(int argc, char *argv[])
Definition: bitcoin.cpp:559
BitcoinApplication::baseInitialize
bool baseInitialize(Config &config)
Basic initialization, before starting initialization/shutdown thread.
Definition: bitcoin.cpp:301
BitcoinApplication::createWindow
void createWindow(const Config *, const NetworkStyle *networkStyle)
Create main window.
Definition: bitcoin.cpp:265
BitcoinApplication::requestedInitialize
void requestedInitialize(Config *config, RPCServer *rpcServer, HTTPRPCRequestProcessor *httpRPCRequestProcessor)
BitcoinApplication::InitializePruneSetting
void InitializePruneSetting(bool prune)
Initialize prune setting.
Definition: bitcoin.cpp:354
WalletController
Controller between interfaces::Node, WalletModel instances and the GUI.
Definition: walletcontroller.h:48
BitcoinABC::initialize
void initialize(Config *config, RPCServer *rpcServer, HTTPRPCRequestProcessor *httpRPCRequestProcessor)
Definition: bitcoin.cpp:185
BitcoinApplication::returnValue
int returnValue
Definition: bitcoin.h:130
BitcoinApplication::createOptionsModel
void createOptionsModel(bool resetSettings)
Create options model.
Definition: bitcoin.cpp:261
BitcoinApplication::coreThread
QThread * coreThread
Definition: bitcoin.h:121
BitcoinApplication::shutdownWindow
std::unique_ptr< QWidget > shutdownWindow
Definition: bitcoin.h:132
BitcoinApplication::requestShutdown
void requestShutdown(Config &config)
Request core shutdown.
Definition: bitcoin.cpp:371
interfaces::Node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:55
BitcoinApplication::window
BitcoinGUI * window
Definition: bitcoin.h:124
ClientModel
Model for Bitcoin network client.
Definition: clientmodel.h:36
BitcoinABC::m_node
interfaces::Node & m_node
Definition: bitcoin.h:56
SplashScreen
Class for the splashscreen with information of the running client.
Definition: splashscreen.h:26
BitcoinApplication::BitcoinApplication
BitcoinApplication()
Definition: bitcoin.cpp:217
BitcoinApplication::startThread
void startThread()
Definition: bitcoin.cpp:305
BitcoinABC::runawayException
void runawayException(const QString &message)
BitcoinApplication::m_splash
SplashScreen * m_splash
Definition: bitcoin.h:133
BitcoinApplication::initializeResult
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Definition: bitcoin.cpp:398
BitcoinApplication::getMainWinId
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
Definition: bitcoin.cpp:478
BitcoinABC::handleRunawayException
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
Definition: bitcoin.cpp:179
BitcoinApplication::windowShown
void windowShown(BitcoinGUI *window)
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:345
BitcoinApplication
Main Bitcoin application object.
Definition: bitcoin.h:60
BitcoinABC::shutdown
void shutdown()
Definition: bitcoin.cpp:201
BitcoinApplication::shutdownResult
void shutdownResult()
Definition: bitcoin.cpp:463
BitcoinApplication::clientModel
ClientModel * clientModel
Definition: bitcoin.h:123