Merge #6090: fix: auto backup issue with descriptor wallets for CJ

bebea4b9b6 fix: auto backup issue with descriptor wallets for CJ (Konstantin Akimov)

Pull request description:

  ## Issue being fixed or feature implemented
  Qt CoinJoin session has problems (https://github.com/dashpay/dash/pull/5579#pullrequestreview-1912946808):
   - Autobackup problems
   - False keypool depletion reporting

  https://github.com/dashpay/dash-issues/issues/59

  ## What was done?
  Disables check for "remaining keys left" and "auto-backups" for non-legacy wallet.

  ## How Has This Been Tested?
  Run unit/functional test
  Try to run CJ mixing for descriptor wallet.

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone

ACKs for top commit:
  PastaPastaPasta:
    utACK bebea4b9b6

Tree-SHA512: 610551001d054c447ddca9451ac6d94f3d063ecf3ccfab437d99324efc5f99ff86e59d80a36f4ff4983d3c8107aa19292c021cb3210fcf51e79919387169c414
This commit is contained in:
pasta 2024-07-02 08:45:25 -05:00
commit 6e5d3f1d1f
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
2 changed files with 24 additions and 15 deletions

View File

@ -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.");

View File

@ -539,6 +539,10 @@ void OverviewPage::coinJoinStatus(bool fForce)
if(walletModel->getKeysLeftSinceAutoBackup() < COINJOIN_KEYS_THRESHOLD_WARNING) {
strKeysLeftText = "<span style='" + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR) + "'>" + strKeysLeftText + "</span>";
}
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!") + "<br><br>" +
@ -607,9 +611,10 @@ 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 (walletModel->wallet().isLegacy()) {
if(nWalletBackups == -1) {
// Automatic backup failed, nothing else we can do until user fixes the issue manually
DisableCoinJoinCompletely();
@ -625,6 +630,7 @@ void OverviewPage::coinJoinStatus(bool fForce)
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
if(nBestHeight != walletModel->coinJoin()->getCachedBlocks()) {