From bebea4b9b676e2cc68ca04575f0e5683247b5ac1 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 1 Jul 2024 20:11:09 +0700 Subject: [PATCH] fix: auto backup issue with descriptor wallets for CJ --- src/coinjoin/client.cpp | 3 +++ src/qt/overviewpage.cpp | 36 +++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index 9c79ef5f52439..e260ca21abeb8 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -715,6 +715,9 @@ bool CCoinJoinClientManager::CheckAutomaticBackup() { if (!CCoinJoinClientOptions::IsEnabled() || !IsMixing()) return false; + // We don't need auto-backups for descriptor wallets + if (!m_wallet.IsLegacy()) return true; + switch (nWalletBackups) { case 0: strAutoDenomResult = _("Automatic backups disabled") + Untranslated(", ") + _("no mixing available."); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index e0a7945591dff..c530787b32241 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -539,6 +539,10 @@ void OverviewPage::coinJoinStatus(bool fForce) if(walletModel->getKeysLeftSinceAutoBackup() < COINJOIN_KEYS_THRESHOLD_WARNING) { strKeysLeftText = "" + strKeysLeftText + ""; } + if (!walletModel->wallet().isLegacy()) { + // we don't need in auto-back for case of Descriptor wallets + strKeysLeftText = ""; + } ui->labelCoinJoinEnabled->setToolTip(strKeysLeftText); QString strCoinJoinName = QString::fromStdString(gCoinJoinName); @@ -553,7 +557,7 @@ void OverviewPage::coinJoinStatus(bool fForce) QString strEnabled = tr("Disabled"); // Show how many keys left in advanced PS UI mode only - if (fShowAdvancedCJUI) strEnabled += ", " + strKeysLeftText; + if (fShowAdvancedCJUI && !strKeysLeftText.isEmpty()) strEnabled += ", " + strKeysLeftText; ui->labelCoinJoinEnabled->setText(strEnabled); // If mixing isn't active always show the lower number of txes because there are @@ -567,7 +571,7 @@ void OverviewPage::coinJoinStatus(bool fForce) // Warn user that wallet is running out of keys // NOTE: we do NOT warn user and do NOT create autobackups if mixing is not running - if (nWalletBackups > 0 && walletModel->getKeysLeftSinceAutoBackup() < COINJOIN_KEYS_THRESHOLD_WARNING) { + if (walletModel->wallet().isLegacy() && nWalletBackups > 0 && walletModel->getKeysLeftSinceAutoBackup() < COINJOIN_KEYS_THRESHOLD_WARNING) { QSettings settings; if(settings.value("fLowKeysWarning").toBool()) { QString strWarn = tr("Very low number of keys left since last automatic backup!") + "

" + @@ -607,23 +611,25 @@ void OverviewPage::coinJoinStatus(bool fForce) QString strEnabled = walletModel->coinJoin()->isMixing() ? tr("Enabled") : tr("Disabled"); // Show how many keys left in advanced PS UI mode only - if(fShowAdvancedCJUI) strEnabled += ", " + strKeysLeftText; + if(fShowAdvancedCJUI && !strKeysLeftText.isEmpty()) strEnabled += ", " + strKeysLeftText; ui->labelCoinJoinEnabled->setText(strEnabled); - if(nWalletBackups == -1) { - // Automatic backup failed, nothing else we can do until user fixes the issue manually - DisableCoinJoinCompletely(); + 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); + 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); + 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); + } } // check coinjoin status and unlock if needed