From cca371c1f671fa668e68bb582a727f02eacf5bcb Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 17 Jun 2026 23:00:25 +0000 Subject: [PATCH] fix(cashu): recover from seed across held mints, not just configured NUT-09 "Recover from seed" iterated only the configured kind:17375 mint list, so funds at a mint dropped from the wallet config (while still holding tokens) or auto-redeemed from a nutzap on an unconfigured mint were silently skipped by recovery. Scan displayMints (configured plus any mint we currently hold tokens at) instead. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01TK5eNfhkNR1svcQxjY1JvR --- .../loggedIn/wallet/CashuWalletViewModel.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/CashuWalletViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/CashuWalletViewModel.kt index 77b7fda99f..dda54daa4b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/CashuWalletViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/CashuWalletViewModel.kt @@ -399,10 +399,16 @@ class CashuWalletViewModel : ViewModel() { val restoreState = _restoreState.asStateFlow() /** - * NUT-09 wallet restore — scans every mint in the wallet's mint list - * for proofs the user previously minted but whose kind:7375 events - * have been lost. Recovered unspent proofs are republished as fresh - * kind:7375 + kind:7376 IN history rows. + * NUT-09 wallet restore — scans every mint we know of for proofs the + * user previously minted but whose kind:7375 events have been lost. + * Recovered unspent proofs are republished as fresh kind:7375 + kind:7376 + * IN history rows. + * + * Scans [CashuWalletState.displayMints] (configured kind:17375 mints plus + * any mint we currently hold tokens at), not just the configured list — + * so a mint dropped from the wallet config while it still holds tokens, + * or one a nutzap was auto-redeemed on, is still recovered rather than + * silently skipped. * * Best-effort across mints: a failure on one mint logs and moves to * the next. The total reported in [RestoreFlowState.Completed] @@ -414,7 +420,7 @@ class CashuWalletViewModel : ViewModel() { _restoreState.value = RestoreFlowState.Running vm.launchSigner { try { - val mintsToScan = state.mints.value + val mintsToScan = state.displayMints.value var totalSats = 0L var totalProofs = 0 for (mint in mintsToScan) {