fix(wallet): don't raise the "needs a repair" dialog after a Compact
Compact runs the node with -salvagewallet to rewrite wallet.dat, which produces the exact same salvage signature in the daemon output as a corruption recovery. So detectWalletAutoRecovery mistook the compaction for a recovery and raised the alarming "Your wallet file needs a quick repair" dialog — whose "Restore original" would have UNDONE the compaction by restoring the larger pre-compact backup. Flag the salvage as expected when we arm it for a compaction (compaction_salvage_expected_, set in both compactWallet and compactViaEmbeddedSwitch, disarmed if the restart is refused). When the detector sees the salvage it consumes the flag and shows a calm "Wallet compacted" toast (compact_done) instead of the recovery dialog. A genuine, unexpected salvage still surfaces the dialog as before. English only for compact_done (8 locales fall back). Build + tests + hygiene green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+14
-3
@@ -241,8 +241,15 @@ void App::detectWalletAutoRecovery()
|
||||
if (wallet_auto_recovered_warned_) return;
|
||||
if (!isUsingEmbeddedDaemon() || !daemon_controller_ || !daemon_controller_->daemon()) return;
|
||||
if (!daemon::walletAutoRecovered(daemon_controller_->daemon()->getOutput())) return;
|
||||
wallet_auto_recovered_warned_ = true; // consume the signature either way — only surfaced once per session
|
||||
// Our own Compact armed this salvage to shrink a HEALTHY wallet — it's not a corruption recovery, so don't
|
||||
// raise the alarming "needs a quick repair" dialog (whose "Restore original" would undo the compaction).
|
||||
if (compaction_salvage_expected_.exchange(false)) {
|
||||
ui::Notifications::instance().success(TR("compact_done"), 12.0f);
|
||||
VERBOSE_LOGF("[recovery] Salvage was our intentional compaction — suppressing the recovery dialog\n");
|
||||
return;
|
||||
}
|
||||
wallet_auto_recovered_ = true;
|
||||
wallet_auto_recovered_warned_ = true;
|
||||
show_wallet_recovered_dialog_ = true;
|
||||
ui::Notifications::instance().info(TR("wallet_recovered_notify"), 30.0f); // calm, not red — coins are safe
|
||||
VERBOSE_LOGF("[recovery] Daemon auto-recovered/salvaged wallet.dat — surfacing the recovery dialog\n");
|
||||
@@ -6518,11 +6525,14 @@ void App::compactWallet()
|
||||
// next start rewrites wallet.dat into a fresh, compact file (and keeps the old one as a timestamped
|
||||
// .bak). It implies a full rescan, so restartDaemon() takes the node down and back up re-scanning.
|
||||
daemon_controller_->setSalvageOnNextStart(true);
|
||||
compaction_salvage_expected_.store(true); // this salvage is a compaction, not a recovery — don't alarm
|
||||
restartDaemon(); // does its own full-node / busy / lifecycle guards and will refuse if the node is busy
|
||||
if (daemon_restarting_.load())
|
||||
if (daemon_restarting_.load()) {
|
||||
n.info(TR("compact_started"));
|
||||
else
|
||||
} else {
|
||||
daemon_controller_->setSalvageOnNextStart(false); // the restart was refused — disarm the stray salvage
|
||||
compaction_salvage_expected_.store(false);
|
||||
}
|
||||
}
|
||||
|
||||
void App::compactViaEmbeddedSwitch()
|
||||
@@ -6565,6 +6575,7 @@ void App::compactViaEmbeddedSwitch()
|
||||
// after the switch our own process is the running node.)
|
||||
setUseEmbeddedDaemon(true);
|
||||
compact_on_embedded_start_.store(true);
|
||||
compaction_salvage_expected_.store(true); // the coming salvage is a compaction — don't alarm
|
||||
ui::Notifications::instance().info(TR("compact_started"));
|
||||
startEmbeddedDaemon();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user