8#include <chainparams.h>
37#include <validation.h>
43#include <QApplication>
46#include <QDragEnterEvent>
52#include <QProgressDialog>
56#include <QStackedWidget>
59#include <QSystemTrayIcon>
69#elif defined(Q_OS_WIN)
130 if (QSystemTrayIcon::isSystemTrayAvailable()) {
145 frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
183 "QProgressBar { background-color: #e8e8e8; border: 1px solid grey; "
184 "border-radius: 7px; padding: 1px; text-align: center; } "
185 "QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, "
186 "x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: "
187 "7px; margin: 0px; }");
249 &QActionGroup::setEnabled);
253 tr(
"&Overview"),
this);
274 tr(
"&Receive"),
this);
276 tr(
"Request payments (generates QR codes and %1: URIs)")
277 .
arg(QString::fromStdString(
290 tr(
"&Transactions"),
this);
304 &BitcoinGUI::gotoOverviewPage);
308 [
this] { gotoSendCoinsPage(); });
312 [
this] { gotoSendCoinsPage(); });
316 &BitcoinGUI::gotoReceiveCoinsPage);
320 &BitcoinGUI::gotoReceiveCoinsPage);
324 &BitcoinGUI::gotoHistoryPage);
349 tr(
"Encrypt the private keys that belong to your wallet"));
355 tr(
"Change the passphrase used for wallet encryption"));
358 tr(
"Sign messages with your Bitcoin addresses to prove you own them"));
361 tr(
"Verify messages to ensure they were signed with specified Bitcoin "
365 tr(
"Load Partially Signed Bitcoin Transaction"));
369 tr(
"Open node debugging and diagnostic console"));
376 tr(
"Show the list of used sending addresses and labels"));
378 new QAction(
tr(
"&Receiving addresses"),
this);
380 tr(
"Show the list of used receiving addresses and labels"));
384 tr(
"Open a %1: URI or payment request")
385 .
arg(QString::fromStdString(
406 tr(
"Show the %1 help message to get a list with possible Bitcoin "
407 "command-line options")
414 tr(
"Mask the values in the Overview tab"));
443 [
this] { gotoSignMessageTab(); });
447 [
this] { gotoVerifyMessageTab(); });
449 [
this] { gotoLoadPSBT(); });
455 &BitcoinGUI::openClicked);
458 for (
const std::pair<const std::string, bool> &i :
460 const std::string &path = i.first;
462 ?
QString(
"[" +
tr(
"default wallet") +
"]")
463 : QString::fromStdString(path);
472 action->setEnabled(
false);
480 &BitcoinGUI::setCurrentWallet);
482 &QObject::deleteLater);
489 action->setEnabled(
false);
499 &BitcoinGUI::setCurrentWallet);
501 &QObject::deleteLater);
512 &QShortcut::activated,
this,
535 file->addSeparator();
541 file->addSeparator();
560 [] { QApplication::activeWindow()->showMinimized(); });
565 (window->flags() & Qt::Dialog) != Qt::Dialog &&
566 window->windowState() != Qt::WindowMinimized);
573 if (window->windowState() != Qt::WindowMaximized) {
574 window->showMaximized();
576 window->showNormal();
611 help->addSeparator();
620 toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
622 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
630 QWidget *
spacer =
new QWidget();
631 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
637 static_cast<void (QComboBox::*)(
int)
>(
638 &QComboBox::currentIndexChanged),
639 this, &BitcoinGUI::setCurrentWalletBySelectorIndex);
672 QDateTime::fromTime_t(
tip_info->header_time),
false);
674 QDateTime::fromTime_t(
tip_info->block_time),
683 unsigned int style) {
745 &BitcoinGUI::addWallet);
747 &BitcoinGUI::removeWallet);
758void BitcoinGUI::addWallet(
WalletModel *walletModel) {
776void BitcoinGUI::removeWallet(
WalletModel *walletModel) {
813void BitcoinGUI::setCurrentWalletBySelectorIndex(
int index) {
821void BitcoinGUI::removeAllWallets() {
850 assert(QSystemTrayIcon::isSystemTrayAvailable());
853 if (QSystemTrayIcon::isSystemTrayAvailable()) {
878 &BitcoinGUI::macosDockIconActivated);
907 if (reason == QSystemTrayIcon::Trigger) {
913void BitcoinGUI::macosDockIconActivated() {
947void BitcoinGUI::openClicked() {
954void BitcoinGUI::gotoOverviewPage() {
961void BitcoinGUI::gotoHistoryPage() {
968void BitcoinGUI::gotoReceiveCoinsPage() {
975void BitcoinGUI::gotoSendCoinsPage(
QString addr) {
982void BitcoinGUI::gotoSignMessageTab(
QString addr) {
988void BitcoinGUI::gotoVerifyMessageTab(
QString addr) {
993void BitcoinGUI::gotoLoadPSBT() {
1005 icon =
":/icons/connect_0";
1010 icon =
":/icons/connect_1";
1015 icon =
":/icons/connect_2";
1020 icon =
":/icons/connect_3";
1023 icon =
":/icons/connect_4";
1030 tooltip =
tr(
"%n active connection(s) to Bitcoin network",
"",
count) +
1031 QString(
".<br>") +
tr(
"Click to disable network activity.");
1034 tr(
"Click to enable network activity again.");
1035 icon =
":/icons/network_disabled";
1062 tr(
"Syncing Headers (%1%)...")
1063 .arg(QString::number(100.0 /
1076 tr(
"Pre-syncing Headers (%1%)…")
1088 dlg.setCurrentTab(tab);
1155 tooltip =
tr(
"Processed %n block(s) of transaction history.",
"",
count);
1186 ->SingleColorIcon(
QString(
":/animation/spinner-%1")
1204 tooltip +=
tr(
"Transactions after this will not yet be visible.");
1222 int nMBoxIcon = QMessageBox::Information;
1226 if (!title.isEmpty()) {
1261 auto buttons =
static_cast<QMessageBox::StandardButton
>(
1270 mBox.setTextFormat(Qt::PlainText);
1272 int r =
mBox.exec();
1273 if (
ret !=
nullptr) {
1274 *
ret = r == QMessageBox::Ok;
1283 QMainWindow::changeEvent(
e);
1285 if (
e->type() == QEvent::WindowStateChange) {
1291 QTimer::singleShot(0,
this, &BitcoinGUI::hide);
1293 }
else if ((
wsevt->oldState() & Qt::WindowMinimized) &&
1295 QTimer::singleShot(0,
this, &BitcoinGUI::show);
1311 QApplication::quit();
1313 QMainWindow::showMinimized();
1318 QMainWindow::closeEvent(event);
1330void BitcoinGUI::incomingTransaction(
const QString &date,
int unit,
1336 QString msg =
tr(
"Date: %1\n").arg(date) +
1340 !walletName.isEmpty()) {
1341 msg +=
tr(
"Wallet: %1\n").arg(walletName);
1343 msg +=
tr(
"Type: %1\n").arg(type);
1344 if (!label.isEmpty()) {
1345 msg +=
tr(
"Label: %1\n").arg(label);
1346 }
else if (!address.isEmpty()) {
1347 msg +=
tr(
"Address: %1\n").arg(address);
1350 :
tr(
"Incoming transaction"),
1357 if (event->mimeData()->hasUrls()) {
1358 event->acceptProposedAction();
1363 if (event->mimeData()->hasUrls()) {
1364 for (
const QUrl &
uri :
event->mimeData()->urls()) {
1368 event->acceptProposedAction();
1373 if (event->type() == QEvent::StatusTip) {
1380 return QMainWindow::eventFilter(
object, event);
1388 gotoSendCoinsPage();
1398 : hdEnabled ?
":/icons/hd_enabled"
1399 :
":/icons/hd_disabled")
1403 : hdEnabled ?
tr(
"HD key generation is <b>enabled</b>")
1404 :
tr(
"HD key generation is <b>disabled</b>"));
1410void BitcoinGUI::setEncryptionStatus(
int status) {
1424 tr(
"Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
1435 tr(
"Wallet is <b>encrypted</b> and currently <b>locked</b>"));
1443void BitcoinGUI::updateWalletStatus() {
1541 trayIcon->setVisible(!fHideTrayIcon);
1554 unsigned int style) {
1564 QString::fromStdString(message.
original);
1569 bool invoked = QMetaObject::invokeMethod(
1584 std::placeholders::_2, std::placeholders::_3));
1587 std::placeholders::_3, std::placeholders::_4));
1605 setToolTip(
tr(
"Unit to show amounts in. Click to select another unit."));
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const bilingual_str &message, const std::string &caption, unsigned int style)
static constexpr int64_t MAX_BLOCK_TIME_GAP
Maximum gap between node time and block time used for the "Catching up..." mode in GUI.
const CChainParams & Params()
Return the currently selected parameters.
void updateHeadersPresyncProgressLabel(int64_t height, const QDateTime &blockDate)
GUIUtil::ClickableProgressBar * progressBar
QAction * m_close_all_wallets_action
void showEvent(QShowEvent *event) override
QLabel * progressBarLabel
QAction * m_open_wallet_action
static const std::string DEFAULT_UIPLATFORM
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state)
Set number of blocks and last block date shown in the UI.
void setClientModel(ClientModel *clientModel=nullptr, interfaces::BlockAndHeaderTipInfo *tip_info=nullptr)
Set the client model.
GUIUtil::ClickableLabel * connectionsControl
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
ModalOverlay * modalOverlay
QAction * changePassphraseAction
void openOptionsDialogWithTab(OptionsDialog::Tab tab)
Open the OptionsDialog on the specified tab index.
QAction * receiveCoinsMenuAction
int prevBlocks
Keep track of previous number of blocks, to detect progress.
QAction * openRPCConsoleAction
const NetworkStyle *const m_network_style
void changeEvent(QEvent *e) override
GUIUtil::ClickableLabel * labelProxyIcon
void optionsClicked()
Show configuration dialog.
bool eventFilter(QObject *object, QEvent *event) override
QMenu * m_open_wallet_menu
QAction * toggleHideAction
void createTrayIcon()
Create system tray icon and notification.
void setPrivacy(bool privacy)
QProgressDialog * progressDialog
std::unique_ptr< interfaces::Handler > m_handler_message_box
WalletFrame * walletFrame
void updateProxyIcon()
Set the proxy-enabled icon as shown in the UI.
QAction * receiveCoinsAction
const std::unique_ptr< QMenu > trayIconMenu
QAction * usedSendingAddressesAction
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
void closeEvent(QCloseEvent *event) override
QAction * verifyMessageAction
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
HelpMessageDialog * helpMessageDialog
void aboutClicked()
Show about dialog.
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
QAction * encryptWalletAction
void updateNetworkState()
Update UI with latest network info from model.
void createActions()
Create the main UI actions.
void showDebugWindow()
Show debug window.
QAction * m_mask_values_action
void consoleShown(RPCConsole *console)
Signal raised when RPC console shown.
bool isPrivacyModeActivated() const
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
void dropEvent(QDropEvent *event) override
void showProgress(const QString &title, int nProgress)
Show progress dialog e.g.
QAction * usedReceivingAddressesAction
void subscribeToCoreSignals()
Connect core signals to GUI client.
void createToolBars()
Create the toolbars.
QAction * m_wallet_selector_action
UnitDisplayStatusBarControl * unitDisplayControl
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
const PlatformStyle * platformStyle
void dragEnterEvent(QDragEnterEvent *event) override
QAction * m_close_wallet_action
QLabel * labelWalletEncryptionIcon
GUIUtil::ClickableLabel * labelBlocksIcon
interfaces::Node & m_node
QAction * m_create_wallet_action
QAction * m_load_psbt_action
void detectShutdown()
called by a timer to check if ShutdownRequested() has been set
QAction * m_wallet_selector_label_action
WalletController * m_wallet_controller
QAction * backupWalletAction
QAction * sendCoinsMenuAction
QAction * showHelpMessageAction
QComboBox * m_wallet_selector
QLabel * m_wallet_selector_label
void showNormalIfMinimized()
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
ClientModel * clientModel
void updateHeadersSyncProgressLabel()
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
void createMenuBar()
Create the menu bar and sub-menus.
QSystemTrayIcon * trayIcon
void message(const QString &title, QString message, unsigned int style, bool *ret=nullptr, const QString &detailed_message=QString())
Notify the user of an event from the core network or transaction handling code.
void showHelpMessageClicked()
Show help message dialog.
QAction * sendCoinsAction
QLabel * labelWalletHDStatusIcon
void setNumConnections(int count)
Set number of connections shown in the UI.
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
QAction * signMessageAction
Notificator * notificator
BitcoinGUI(interfaces::Node &node, const Config *, const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent=nullptr)
std::unique_ptr< interfaces::Handler > m_handler_question
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
static QString formatWithUnit(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
static QString longName(int unit)
Long name.
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
Unit
Currency units Please add only sensible ones.
const Consensus::Params & GetConsensus() const
const std::string & CashAddrPrefix() const
Signals for UI communication.
@ BTN_MASK
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated,...
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
@ MODAL
Force blocking, modal message box dialog (not just OS notification)
Model for Bitcoin network client.
void showProgress(const QString &title, int nProgress)
int getHeaderTipHeight() const
int getNumConnections(NumConnections flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
void numConnectionsChanged(int count)
BlockSource getBlockSource() const
Returns the block source of the current importing/syncing state.
int64_t getHeaderTipTime() const
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType header, SynchronizationState sync_state)
OptionsModel * getOptionsModel()
bool getProxyInfo(std::string &ip_port) const
void networkActiveChanged(bool networkActive)
virtual const CChainParams & GetChainParams() const =0
void created(WalletModel *wallet_model)
void clicked(const QPoint &point)
Emitted when the label is clicked.
void clicked(const QPoint &point)
Emitted when the progressbar is clicked.
"Help message" dialog box
macOS-specific Dock icon handler.
static MacDockIconHandler * instance()
Modal overlay to display information about the chain-sync state.
void showHide(bool hide=false, bool userRequested=false)
void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress)
void triggered(bool hidden)
bool isLayerVisible() const
void setKnownBestHeight(int count, const QDateTime &blockDate, bool presync)
const QIcon & getTrayAndWindowIcon() const
const QString & getTitleAddText() const
Cross-platform desktop notification client.
@ Information
Informational message.
@ Critical
An error occurred.
@ Warning
Notify user of potential problem.
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
void opened(WalletModel *wallet_model)
Interface from Qt to configuration data structure for Bitcoin client.
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void displayUnitChanged(int unit)
bool getMinimizeToTray() const
bool getMinimizeOnClose() const
bool getHideTrayIcon() const
void hideTrayIconChanged(bool)
Local Bitcoin RPC console.
std::vector< TabTypes > tabs() const
QString tabTitle(TabTypes tab_type) const
QKeySequence tabShortcut(TabTypes tab_type) const
void addWallet(WalletModel *const walletModel)
void removeWallet(WalletModel *const walletModel)
void setClientModel(ClientModel *model=nullptr, int bestblock_height=0, int64_t bestblock_date=0, double verification_progress=0.0)
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
void mousePressEvent(QMouseEvent *event) override
So that it responds to left-button clicks.
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events.
OptionsModel * optionsModel
UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
Controller between interfaces::Node, WalletModel instances and the GUI.
void walletAdded(WalletModel *wallet_model)
void closeAllWallets(QWidget *parent=nullptr)
std::map< std::string, bool > listWalletDir() const
Returns all wallet names in the wallet dir mapped to whether the wallet is loaded.
void walletRemoved(WalletModel *wallet_model)
void closeWallet(WalletModel *wallet_model, QWidget *parent=nullptr)
A container for embedding all wallet-related controls into BitcoinGUI.
bool addWallet(WalletModel *walletModel)
void changePassphrase()
Change encrypted wallet passphrase.
void requestedSyncWarningInfo()
Notify that the user has requested more information about the out-of-sync warning.
WalletModel * currentWalletModel() const
void gotoHistoryPage()
Switch to history (transactions) page.
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
WalletView * currentWalletView() const
void gotoOverviewPage()
Switch to overview (home) page.
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
void removeWallet(WalletModel *wallet_model)
void setClientModel(ClientModel *clientModel)
void backupWallet()
Backup the wallet.
void usedSendingAddresses()
Show used sending addresses.
void encryptWallet()
Encrypt the wallet.
void gotoLoadPSBT()
Load Partially Signed Bitcoin Transaction.
void usedReceivingAddresses()
Show used receiving addresses.
void setCurrentWallet(WalletModel *wallet_model)
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
void showOutOfSyncWarning(bool fShow)
void gotoReceiveCoinsPage()
Switch to receive coins page.
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
Interface to Bitcoin wallet from Qt view code.
EncryptionStatus getEncryptionStatus() const
interfaces::Wallet & wallet() const
QString getDisplayName() const
static bool isWalletEnabled()
Top-level interface for a bitcoin node (bitcoind process).
virtual void setNetworkActive(bool active)=0
Set network active.
virtual std::unique_ptr< Handler > handleMessageBox(MessageBoxFn fn)=0
virtual bool getNetworkActive()=0
Get network active.
virtual std::unique_ptr< Handler > handleQuestion(QuestionFn fn)=0
virtual WalletClient & walletClient()=0
Get wallet client.
virtual bool shutdownRequested()=0
Return whether shutdown was requested.
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
virtual bool hdEnabled()=0
virtual bool privateKeysDisabled()=0
static const int STATUSBAR_ICONSIZE
static constexpr int HEADER_HEIGHT_DELTA_SYNC
The required delta of headers to the estimated number of available headers until we show the IBD prog...
bool isObscured(QWidget *w)
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
void handleCloseWindowShortcut(QWidget *w)
void PolishProgressDialog(QProgressDialog *dialog)
ClickableProgressBar ProgressBar
void bringToFront(QWidget *w)
QString formatNiceTimeOffset(qint64 secs)
int TextWidth(const QFontMetrics &fm, const QString &text)
Returns the distance in pixels appropriate for drawing a subsequent character after text.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
static constexpr Amount zero() noexcept
int64_t nPowTargetSpacing
Block and header tip information.
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
SynchronizationState
Current sync state passed to tip changed callbacks.