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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TK5eNfhkNR1svcQxjY1JvR
This commit is contained in:
Claude
2026-06-17 23:00:25 +00:00
parent f9c8ce0213
commit cca371c1f6
@@ -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) {