fix(ui): only toast "Blockchain rescan complete" for user-initiated rescans
The daemon-output parser treats autonomous background witness rebuilds as a rescan (they set state_.sync.rescanning via the foundWitness branch), so one completing fired "Blockchain rescan complete" even though the user never started a rescan — most visibly after a minimize, where a whole rebuild's start+finish arrives in one batch. Add user_initiated_rescan_ (atomic — some triggers run on worker threads), set it at the wallet's real rescan triggers (the Rescan button, a -rescan/salvage/zap/reindex restart, key import, seed migration), and gate the three "rescan complete" toasts on it, clearing it when shown. The rescan/witness progress state machine is untouched — only the toast is gated — so background rebuilds no longer announce a completed rescan while genuine user rescans still do (and can't double-toast). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+8
-3
@@ -1365,6 +1365,7 @@ void App::switchToWallet(const std::string& walletFile, bool stopDaemonConfirmed
|
||||
if (daemon_controller_) daemon_controller_->clearExternalDaemonDetected();
|
||||
if (salvage && daemon_controller_) daemon_controller_->setSalvageOnNextStart(true); // repair a corrupt wallet
|
||||
else if (needRescan && daemon_controller_) daemon_controller_->setRescanOnNextStart(true); // (salvage implies rescan)
|
||||
if (salvage || needRescan) user_initiated_rescan_ = true; // wallet-triggered repair/rescan → completion should toast
|
||||
// Start ONCE. Do NOT retry-spawn: a second start while the first is still shutting down leaves
|
||||
// two dragonxd holding wallet.dat against each other (BDB "Failed to rename … Error"). The
|
||||
// stopDaemonForWalletSwitch() wait already ensured the old node's process is gone, so a valid
|
||||
@@ -1680,7 +1681,10 @@ void App::refreshCoreData()
|
||||
transactions_dirty_ = true;
|
||||
last_tx_block_height_ = -1;
|
||||
invalidateShieldedHistoryScanProgress(true);
|
||||
ui::Notifications::instance().success("Blockchain rescan complete");
|
||||
if (user_initiated_rescan_) {
|
||||
ui::Notifications::instance().success("Blockchain rescan complete");
|
||||
user_initiated_rescan_ = false; // surfaced once; not for background rebuilds
|
||||
}
|
||||
}
|
||||
|
||||
NetworkRefreshService::applyConnectionInfoResult(state_, result.info);
|
||||
@@ -4831,7 +4835,7 @@ void App::beginAdoptSeedWallet()
|
||||
|
||||
// 3. Rescan on next start (only if the swap happened) and bring the daemon back up —
|
||||
// unless we're quitting, in which case don't resurrect it.
|
||||
if (swapDone && daemon_controller_) daemon_controller_->setRescanOnNextStart(true);
|
||||
if (swapDone && daemon_controller_) { daemon_controller_->setRescanOnNextStart(true); user_initiated_rescan_ = true; }
|
||||
if (!shutting_down_) {
|
||||
// We stopped the daemon ourselves (port_free) — clear the adopted-external latch so the
|
||||
// relaunched process is treated as owned (stop/isRunning/exit behave normally afterward).
|
||||
@@ -5130,7 +5134,7 @@ void App::rebuildWalletDatabase()
|
||||
fs::rename(datadir + "/database", datadir + "/database.prerebuild-" + std::string(ts) + ".bak", e2);
|
||||
for (const auto& e : fs::directory_iterator(datadir, e2))
|
||||
if (e.path().filename().string().rfind("__db.", 0) == 0) { std::error_code e3; fs::remove(e.path(), e3); }
|
||||
if (daemon_controller_) daemon_controller_->setRescanOnNextStart(true);
|
||||
if (daemon_controller_) { daemon_controller_->setRescanOnNextStart(true); user_initiated_rescan_ = true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5558,6 +5562,7 @@ void App::runtimeRescan(int startHeight)
|
||||
runtime_rescan_active_ = true;
|
||||
state_.sync.rescanning = true;
|
||||
rescan_confirmed_active_ = true;
|
||||
user_initiated_rescan_ = true; // user clicked Rescan → completion should toast
|
||||
state_.sync.rescan_progress = 0.0f;
|
||||
state_.sync.rescan_status = "Rescanning from block " + std::to_string(startHeight) + "...";
|
||||
transactions_dirty_ = true;
|
||||
|
||||
Reference in New Issue
Block a user