From 7138f633a85fb1666ea72e7ffcc70cc2f7c1d73a Mon Sep 17 00:00:00 2001 From: DanS Date: Mon, 26 Oct 2026 14:56:22 -0500 Subject: [PATCH] feat(wallet): enable auto-consolidation by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default the auto_consolidate setting to true, so a full-node wallet keeps its note count down on its own out of the box (users can still turn it off). A missing key in an older config loads the new default, enabling it on upgrade, which is intended. The page-state mirror default matches. Safety is unchanged and reinforced in comments: auto-consolidation reuses the "keep in each address" engine — z_mergetoaddress [addr] -> addr — so funds NEVER move between addresses; it only sheds notes within each address. It never uses the "into one address" sweep. It also only runs when the wallet is idle AND unlocked (a locked encrypted wallet never auto-runs) and only touches addresses with more than kAutoConsolidateMinNotes notes, so a fresh or lean wallet stays dormant. Build + tests + hygiene green. Co-Authored-By: Claude Opus 4.8 --- src/app_network.cpp | 3 +++ src/config/settings.h | 6 ++++-- src/ui/pages/settings_page.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app_network.cpp b/src/app_network.cpp index 1224927..0fdcc56 100644 --- a/src/app_network.cpp +++ b/src/app_network.cpp @@ -6374,6 +6374,9 @@ void App::finishConsolidation() // Start the shared ConsolidationRun with the SAME guards as startConsolidation but SILENTLY and with a // caller-chosen (gentle) config — the background driver's entry point. No toasts; marks the run as ours. +// Like the manual "keep in each address" mode, this run merges every address's notes back into THAT SAME +// address (z_mergetoaddress [addr] -> addr in postConsolidationCall), so auto-consolidation NEVER moves +// funds between addresses — it only sheds notes. It never uses the "into one address" sweep. bool App::startConsolidationQuiet(const std::vector& groups, services::RunConfig cfg) { if (isLiteBuild() || capture_mode_ || shutting_down_.load()) return false; diff --git a/src/config/settings.h b/src/config/settings.h index f2e7387..07b2ec1 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -230,7 +230,9 @@ public: bool getAutoShield() const { return auto_shield_; } void setAutoShield(bool shield) { auto_shield_ = shield; } // Automatic background note consolidation (full-node): when on, the wallet quietly merges small notes - // in tiny batches while idle (see App::pumpAutoConsolidation). Off by default. + // in tiny batches while idle (see App::pumpAutoConsolidation). Each address's notes are merged back into + // THAT SAME address (z_mergetoaddress [addr] -> addr), so funds never move between addresses. On by + // default — a missing key in an older config therefore enables it on upgrade, which is intended. bool getAutoConsolidate() const { return auto_consolidate_; } void setAutoConsolidate(bool v) { auto_consolidate_ = v; } @@ -731,7 +733,7 @@ private: int time_format_ = 0; // global clock: 0 = 24h, 1 = 12h bool save_ztxs_ = true; bool auto_shield_ = true; - bool auto_consolidate_ = false; + bool auto_consolidate_ = true; bool use_tor_ = false; bool allow_custom_fees_ = false; double default_fee_ = 0.0001; diff --git a/src/ui/pages/settings_page.cpp b/src/ui/pages/settings_page.cpp index 4d501b7..717b9c1 100644 --- a/src/ui/pages/settings_page.cpp +++ b/src/ui/pages/settings_page.cpp @@ -92,7 +92,7 @@ struct SettingsPageState { bool save_ztxs = true; bool allow_custom_fees = false; bool auto_shield = false; - bool auto_consolidate = false; + bool auto_consolidate = true; // on by default (loaded from settings on open; see getAutoConsolidate) bool fetch_prices = true; bool use_tor = false; char rpc_host[128] = DRAGONX_DEFAULT_RPC_HOST;