fix(wallet): correct Compact's behaviour with an external daemon
Compact rewrites wallet.dat by restarting the node with -salvagewallet, which the wallet can only do for the EMBEDDED node it manages. When the wallet is connected to a dragonxd the user started themselves (use-embedded off, or it attached to an already-running node), daemon_controller_ is null — and compactWallet() fired the misleading "unavailable in lite build" warning even on a full-node wallet. Now: a precise App::canCompactWallet() (full-node AND embedded AND a live controller) disables the Compact button for an external/standalone daemon with a tooltip, and compactWallet() refuses with an accurate message (compact_needs_ embedded) that tells the user to enable "Use embedded dragonxd" or restart their dragonxd with -salvagewallet themselves. The lite-build path keeps its own message. New string compact_needs_embedded (English; 8 locales fall back). Build + tests + hygiene green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+8
-1
@@ -6503,10 +6503,17 @@ void App::maybeWarnLargeWallet()
|
||||
void App::compactWallet()
|
||||
{
|
||||
auto& n = ui::Notifications::instance();
|
||||
if (!supportsFullNodeLifecycleActions() || !daemon_controller_) {
|
||||
if (!supportsFullNodeLifecycleActions()) {
|
||||
n.warning(TR("appx_fullnode_lifecycle_unavailable_lite"));
|
||||
return;
|
||||
}
|
||||
// Compacting rewrites wallet.dat by restarting the node with -salvagewallet — only possible when the
|
||||
// wallet MANAGES the node (the embedded daemon). With an external dragonxd there is no controller to
|
||||
// restart, so tell the user how to do it themselves instead of the misleading lite-build message.
|
||||
if (!isUsingEmbeddedDaemon() || !daemon_controller_) {
|
||||
n.warning(TR("compact_needs_embedded"));
|
||||
return;
|
||||
}
|
||||
// Consolidation frees internal BDB pages but never returns the space to the OS; -salvagewallet on the
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user