2022-12-24 23:49:50 +00:00
|
|
|
// Copyright (c) 2011-2022 The Bitcoin Core developers
|
2018-05-18 16:41:56 -04:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_QT_BITCOIN_H
|
|
|
|
#define BITCOIN_QT_BITCOIN_H
|
|
|
|
|
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include <config/bitcoin-config.h>
|
|
|
|
#endif
|
|
|
|
|
2021-07-14 11:48:21 +03:00
|
|
|
#include <interfaces/node.h>
|
2021-07-14 12:03:25 +03:00
|
|
|
#include <qt/initexecutor.h>
|
2021-07-14 11:48:21 +03:00
|
|
|
|
2018-08-23 13:42:31 -04:00
|
|
|
#include <assert.h>
|
2018-05-18 16:41:56 -04:00
|
|
|
#include <memory>
|
2021-07-14 11:48:21 +03:00
|
|
|
#include <optional>
|
2018-05-18 16:41:56 -04:00
|
|
|
|
2021-07-14 11:48:21 +03:00
|
|
|
#include <QApplication>
|
2020-05-19 15:15:00 +02:00
|
|
|
|
2018-05-18 16:41:56 -04:00
|
|
|
class BitcoinGUI;
|
|
|
|
class ClientModel;
|
|
|
|
class NetworkStyle;
|
|
|
|
class OptionsModel;
|
|
|
|
class PaymentServer;
|
|
|
|
class PlatformStyle;
|
2018-08-23 13:42:31 -04:00
|
|
|
class SplashScreen;
|
2019-01-04 18:49:48 +00:00
|
|
|
class WalletController;
|
2018-05-18 16:41:56 -04:00
|
|
|
class WalletModel;
|
2017-12-05 15:57:12 -05:00
|
|
|
namespace interfaces {
|
|
|
|
class Init;
|
|
|
|
} // namespace interfaces
|
2018-05-18 16:41:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
/** Main Bitcoin application object */
|
|
|
|
class BitcoinApplication: public QApplication
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-08-23 13:42:31 -04:00
|
|
|
explicit BitcoinApplication();
|
2018-05-18 16:41:56 -04:00
|
|
|
~BitcoinApplication();
|
|
|
|
|
|
|
|
#ifdef ENABLE_WALLET
|
|
|
|
/// Create payment server
|
|
|
|
void createPaymentServer();
|
|
|
|
#endif
|
|
|
|
/// parameter interaction/setup based on rules
|
|
|
|
void parameterSetup();
|
|
|
|
/// Create options model
|
2019-04-29 15:29:00 -04:00
|
|
|
[[nodiscard]] bool createOptionsModel(bool resetSettings);
|
2020-01-07 22:08:55 +02:00
|
|
|
/// Initialize prune setting
|
2020-04-20 14:42:52 +00:00
|
|
|
void InitPruneSetting(int64_t prune_MiB);
|
2018-05-18 16:41:56 -04:00
|
|
|
/// Create main window
|
|
|
|
void createWindow(const NetworkStyle *networkStyle);
|
|
|
|
/// Create splash screen
|
|
|
|
void createSplashScreen(const NetworkStyle *networkStyle);
|
2017-12-05 15:57:12 -05:00
|
|
|
/// Create or spawn node
|
|
|
|
void createNode(interfaces::Init& init);
|
2017-11-06 20:11:43 -05:00
|
|
|
/// Basic initialization, before starting initialization/shutdown thread. Return true on success.
|
|
|
|
bool baseInitialize();
|
2018-05-18 16:41:56 -04:00
|
|
|
|
|
|
|
/// Request core initialization
|
|
|
|
void requestInitialize();
|
|
|
|
|
|
|
|
/// Get process return value
|
|
|
|
int getReturnValue() const { return returnValue; }
|
|
|
|
|
|
|
|
/// Get window identifier of QMainWindow (BitcoinGUI)
|
|
|
|
WId getMainWinId() const;
|
|
|
|
|
|
|
|
/// Setup platform style
|
|
|
|
void setupPlatformStyle();
|
|
|
|
|
2018-08-23 13:42:31 -04:00
|
|
|
interfaces::Node& node() const { assert(m_node); return *m_node; }
|
|
|
|
|
2018-05-18 16:41:56 -04:00
|
|
|
public Q_SLOTS:
|
2020-05-19 15:15:00 +02:00
|
|
|
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
|
2021-06-07 18:45:04 +03:00
|
|
|
/// Request core shutdown
|
|
|
|
void requestShutdown();
|
2018-05-18 16:41:56 -04:00
|
|
|
/// Handle runaway exceptions. Shows a message box with the problem and quits the program.
|
|
|
|
void handleRunawayException(const QString &message);
|
|
|
|
|
2021-03-27 18:52:22 +02:00
|
|
|
/**
|
|
|
|
* A helper function that shows a message box
|
|
|
|
* with details about a non-fatal exception.
|
|
|
|
*/
|
|
|
|
void handleNonFatalException(const QString& message);
|
|
|
|
|
2018-05-18 16:41:56 -04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void requestedInitialize();
|
|
|
|
void requestedShutdown();
|
2017-11-06 20:11:43 -05:00
|
|
|
void windowShown(BitcoinGUI* window);
|
2018-05-18 16:41:56 -04:00
|
|
|
|
2022-02-12 15:37:43 +02:00
|
|
|
protected:
|
|
|
|
bool event(QEvent* e) override;
|
|
|
|
|
2018-05-18 16:41:56 -04:00
|
|
|
private:
|
2021-07-14 19:03:42 +03:00
|
|
|
std::optional<InitExecutor> m_executor;
|
2022-12-16 11:58:38 +00:00
|
|
|
OptionsModel* optionsModel{nullptr};
|
|
|
|
ClientModel* clientModel{nullptr};
|
|
|
|
BitcoinGUI* window{nullptr};
|
|
|
|
QTimer* pollShutdownTimer{nullptr};
|
2018-05-18 16:41:56 -04:00
|
|
|
#ifdef ENABLE_WALLET
|
2019-01-04 18:49:48 +00:00
|
|
|
PaymentServer* paymentServer{nullptr};
|
|
|
|
WalletController* m_wallet_controller{nullptr};
|
2018-05-18 16:41:56 -04:00
|
|
|
#endif
|
2022-12-16 11:58:38 +00:00
|
|
|
int returnValue{0};
|
|
|
|
const PlatformStyle* platformStyle{nullptr};
|
2018-05-18 16:41:56 -04:00
|
|
|
std::unique_ptr<QWidget> shutdownWindow;
|
2018-08-23 13:42:31 -04:00
|
|
|
SplashScreen* m_splash = nullptr;
|
2017-12-05 15:57:12 -05:00
|
|
|
std::unique_ptr<interfaces::Node> m_node;
|
2018-05-18 16:41:56 -04:00
|
|
|
|
|
|
|
void startThread();
|
|
|
|
};
|
|
|
|
|
2017-11-06 20:11:43 -05:00
|
|
|
int GuiMain(int argc, char* argv[]);
|
|
|
|
|
2018-05-18 16:41:56 -04:00
|
|
|
#endif // BITCOIN_QT_BITCOIN_H
|