Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_QT_BITCOINGUI_H6#define BITCOIN_QT_BITCOINGUI_H8#include <bitcoin-build-config.h> // IWYU pragma: keep10#include <qt/bitcoinunits.h>11#include <qt/clientmodel.h>12#include <qt/guiutil.h>13#include <qt/optionsdialog.h>15#include <consensus/amount.h>17#include <QLabel>18#include <QMainWindow>19#include <QMap>20#include <QMenu>21#include <QPoint>22#include <QSystemTrayIcon>24#ifdef Q_OS_MACOS25#include <qt/macos_appnap.h>26#endif28#include <memory>30class NetworkStyle;31class Notificator;32class OptionsModel;33class PlatformStyle;34class RPCConsole;35class SendCoinsRecipient;36class UnitDisplayStatusBarControl;37class WalletController;38class WalletFrame;39class WalletModel;40class HelpMessageDialog;41class ModalOverlay;42enum class SynchronizationState;44namespace interfaces {45class Handler;46class Node;47struct BlockAndHeaderTipInfo;48}50QT_BEGIN_NAMESPACE51class QAction;52class QComboBox;53class QDateTime;54class QProgressBar;55class QProgressDialog;56QT_END_NAMESPACE58namespace GUIUtil {59class ClickableLabel;60class ClickableProgressBar;61}63/**64Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and65wallet models to give the user an up-to-date view of the current core state.66*/67class BitcoinGUI : public QMainWindow68{69Q_OBJECT71public:72static const std::string DEFAULT_UIPLATFORM;74explicit BitcoinGUI(interfaces::Node& node, const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent = nullptr);75~BitcoinGUI();77/** Set the client model.78The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.79*/80void setClientModel(ClientModel *clientModel = nullptr, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);81#ifdef ENABLE_WALLET82void setWalletController(WalletController* wallet_controller, bool show_loading_minimized);83WalletController* getWalletController();84#endif86#ifdef ENABLE_WALLET87/** Set the wallet model.88The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending89functionality.90*/91void addWallet(WalletModel* walletModel);92void removeWallet(WalletModel* walletModel);93void removeAllWallets();94#endif // ENABLE_WALLET95bool enableWallet = false;97/** Get the tray icon status.98Some systems have not "system tray" or "notification area" available.99*/100bool hasTrayIcon() const { return trayIcon; }102/** Disconnect core signals from GUI client */103void unsubscribeFromCoreSignals();105bool isPrivacyModeActivated() const;107protected:108void changeEvent(QEvent *e) override;109void closeEvent(QCloseEvent *event) override;110void showEvent(QShowEvent *event) override;111void dragEnterEvent(QDragEnterEvent *event) override;112void dropEvent(QDropEvent *event) override;113bool eventFilter(QObject *object, QEvent *event) override;115private:116interfaces::Node& m_node;117#ifdef ENABLE_WALLET118WalletController* m_wallet_controller{nullptr};119#endif // ENABLE_WALLET120std::unique_ptr<interfaces::Handler> m_handler_message_box;121std::unique_ptr<interfaces::Handler> m_handler_question;122ClientModel* clientModel = nullptr;123WalletFrame* walletFrame = nullptr;125UnitDisplayStatusBarControl* unitDisplayControl = nullptr;126GUIUtil::ThemedLabel* labelWalletEncryptionIcon = nullptr;127GUIUtil::ThemedLabel* labelWalletHDStatusIcon = nullptr;128GUIUtil::ClickableLabel* labelProxyIcon = nullptr;129GUIUtil::ClickableLabel* connectionsControl = nullptr;130GUIUtil::ClickableLabel* labelBlocksIcon = nullptr;131QLabel* progressBarLabel = nullptr;132GUIUtil::ClickableProgressBar* progressBar = nullptr;133QProgressDialog* progressDialog = nullptr;135QMenuBar* appMenuBar = nullptr;136QToolBar* appToolBar = nullptr;137QAction* overviewAction = nullptr;138QAction* historyAction = nullptr;139QAction* quitAction = nullptr;140QAction* sendCoinsAction = nullptr;141QAction* usedSendingAddressesAction = nullptr;142QAction* usedReceivingAddressesAction = nullptr;143QAction* signMessageAction = nullptr;144QAction* verifyMessageAction = nullptr;145QAction* m_load_psbt_action = nullptr;146QAction* m_load_psbt_clipboard_action = nullptr;147QAction* aboutAction = nullptr;148QAction* receiveCoinsAction = nullptr;149QAction* optionsAction = nullptr;150QAction* encryptWalletAction = nullptr;151QAction* backupWalletAction = nullptr;152QAction* changePassphraseAction = nullptr;153QAction* aboutQtAction = nullptr;154QAction* openRPCConsoleAction = nullptr;155QAction* openAction = nullptr;156QAction* showHelpMessageAction = nullptr;157QAction* m_create_wallet_action{nullptr};158QAction* m_open_wallet_action{nullptr};159QMenu* m_open_wallet_menu{nullptr};160QAction* m_restore_wallet_action{nullptr};161QAction* m_close_wallet_action{nullptr};162QAction* m_close_all_wallets_action{nullptr};163#ifdef ENABLE_WALLET164QAction* m_wallet_selector_label_action = nullptr;165QAction* m_wallet_selector_action = nullptr;166#endif // ENABLE_WALLET167QAction* m_mask_values_action{nullptr};168QAction* m_migrate_wallet_action{nullptr};169QMenu* m_migrate_wallet_menu{nullptr};170QAction* m_export_watchonly_action{nullptr};171#ifdef ENABLE_WALLET172QLabel *m_wallet_selector_label = nullptr;173QComboBox* m_wallet_selector = nullptr;174#endif // ENABLE_WALLET175QSystemTrayIcon* trayIcon = nullptr;176const std::unique_ptr<QMenu> trayIconMenu;177Notificator* notificator = nullptr;178RPCConsole* rpcConsole = nullptr;179HelpMessageDialog* helpMessageDialog = nullptr;180ModalOverlay* modalOverlay = nullptr;182QMenu* m_network_context_menu = new QMenu(this);184#ifdef Q_OS_MACOS185CAppNapInhibitor* m_app_nap_inhibitor = nullptr;186#endif188/** Keep track of previous number of blocks, to detect progress */189int prevBlocks = 0;190int spinnerFrame = 0;192const PlatformStyle *platformStyle;193const NetworkStyle* const m_network_style;195/** Create the main UI actions. */196void createActions();197/** Create the menu bar and sub-menus. */198void createMenuBar();199/** Create the toolbars */200void createToolBars();201/** Create system tray icon and notification */202void createTrayIcon();203/** Create system tray menu (or setup the dock menu) */204void createTrayIconMenu();206/** Enable or disable all wallet-related actions */207void setWalletActionsEnabled(bool enabled);209/** Connect core signals to GUI client */210void subscribeToCoreSignals();212/** Update UI with latest network info from model. */213void updateNetworkState();215void updateHeadersSyncProgressLabel();216void updateHeadersPresyncProgressLabel(int64_t height, const QDateTime& blockDate);218/** Open the OptionsDialog on the specified tab index */219void openOptionsDialogWithTab(OptionsDialog::Tab tab);221Q_SIGNALS:222void quitRequested();223/** Signal raised when a URI was entered or dragged to the GUI */224void receivedURI(const QString &uri);225/** Signal raised when RPC console shown */226void consoleShown(RPCConsole* console);227void setPrivacy(bool privacy);229public Q_SLOTS:230/** Set number of connections shown in the UI */231void setNumConnections(int count);232/** Set network state shown in the UI */233void setNetworkActive(bool network_active);234/** Set number of blocks and last block date shown in the UI */235void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state);236/** Launch the wallet creation modal (no-op if wallet is not compiled) **/237void createWallet();239/** Notify the user of an event from the core network or transaction handling code.240@param[in] title the message box / notification title241@param[in] message the displayed text242@param[in] style modality and style definitions (icon and used buttons - buttons only for message boxes)243@see CClientUIInterface::MessageBoxFlags244@param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only)245@param[in] detailed_message the text to be displayed in the details area246*/247void message(const QString& title, QString message, unsigned int style, bool* ret = nullptr, const QString& detailed_message = QString());249#ifdef ENABLE_WALLET250void setCurrentWallet(WalletModel* wallet_model);
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.