diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index c09ebd86c435..9ce945530a5b 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -526,8 +526,14 @@ void OverviewPage::coinJoinStatus(bool fForce) // Disable any PS UI for masternode or when autobackup is disabled or failed for whatever reason if (clientModel->node().isMasternode() || nWalletBackups <= 0) { DisableCoinJoinCompletely(); - if (nWalletBackups <= 0) { + if (nWalletBackups == 0) { ui->labelCoinJoinEnabled->setToolTip(tr("Automatic backups are disabled, no mixing available!")); + } else if (nWalletBackups == -1) { + ui->labelCoinJoinEnabled->setToolTip(tr("ERROR! Failed to create automatic backup") + ", " + + tr("see debug.log for details.") + "

" + + tr("Mixing is disabled, please close your wallet and fix the issue!")); + } else if (nWalletBackups == -2) { + ui->labelCoinJoinEnabled->setToolTip(tr("WARNING! Failed to replenish keypool, please unlock your wallet to do so.")); } return; } @@ -666,22 +672,11 @@ void OverviewPage::coinJoinStatus(bool fForce) if(fShowAdvancedCJUI && !strKeysLeftText.isEmpty()) strEnabled += ", " + strKeysLeftText; ui->labelCoinJoinEnabled->setText(strEnabled); - if (walletModel->wallet().isLegacy()) { - if(nWalletBackups == -1) { - // Automatic backup failed, nothing else we can do until user fixes the issue manually - DisableCoinJoinCompletely(); - - QString strError = tr("ERROR! Failed to create automatic backup") + ", " + - tr("see debug.log for details.") + "

" + - tr("Mixing is disabled, please close your wallet and fix the issue!"); - ui->labelCoinJoinEnabled->setToolTip(strError); - - return; - } else if(nWalletBackups == -2) { - // We were able to create automatic backup but keypool was not replenished because wallet is locked. - QString strWarning = tr("WARNING! Failed to replenish keypool, please unlock your wallet to do so."); - ui->labelCoinJoinEnabled->setToolTip(strWarning); - } + if (walletModel->wallet().isLegacy() && nWalletBackups == -1) { + // Automatic backup failed, nothing else we can do until user fixes the issue manually. + // Stop mixing right away; the guard above sets the matching tooltip on the next timer tick. + DisableCoinJoinCompletely(); + return; } // check coinjoin status and unlock if needed diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index f051563a8532..1394ac1fdea1 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -193,6 +194,30 @@ void TestGUI(interfaces::Node& node) QString balanceComparison = BitcoinUnits::floorHtmlWithPrivacy(unit, balance, BitcoinUnits::SeparatorStyle::ALWAYS, false); QCOMPARE(balanceText, balanceComparison); + // Check that each autobackup failure state selects its specific tooltip on the CoinJoin status label + { + QLabel* coinJoinLabel = overviewPage.findChild("labelCoinJoinEnabled"); + QVERIFY(coinJoinLabel != nullptr); + const int nWalletBackupsOld = nWalletBackups; + + nWalletBackups = 0; + overviewPage.coinJoinStatus(/*fForce=*/true); + QCOMPARE(coinJoinLabel->toolTip(), QString("Automatic backups are disabled, no mixing available!")); + + nWalletBackups = -1; + overviewPage.coinJoinStatus(/*fForce=*/true); + QCOMPARE(coinJoinLabel->toolTip(), + QString("ERROR! Failed to create automatic backup, see debug.log for details.

Mixing is " + "disabled, please close your wallet and fix the issue!")); + + nWalletBackups = -2; + overviewPage.coinJoinStatus(/*fForce=*/true); + QCOMPARE(coinJoinLabel->toolTip(), + QString("WARNING! Failed to replenish keypool, please unlock your wallet to do so.")); + + nWalletBackups = nWalletBackupsOld; + } + // Check Request Payment button ReceiveCoinsDialog receiveCoinsDialog; receiveCoinsDialog.setModel(&walletModel);