From 73a0261af6fcbed52fb8b0830cb1a0e6f4a43ae3 Mon Sep 17 00:00:00 2001 From: Forte11Cuba Date: Sun, 19 Apr 2026 06:18:51 -0600 Subject: [PATCH] fix: run mint-quote recovery before checkAllMintQuotes --- lib/providers/wallet_provider.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/providers/wallet_provider.dart b/lib/providers/wallet_provider.dart index 3308a60..c031361 100644 --- a/lib/providers/wallet_provider.dart +++ b/lib/providers/wallet_provider.dart @@ -1836,6 +1836,13 @@ class WalletProvider extends ChangeNotifier { /// Llamar en background al iniciar la app. /// También vincula transacciones incoming sin metadata con invoices pendientes. Future checkPendingTransactions() async { + // Recover paid-but-unissued quotes by quote_id FIRST, before the + // per-mint loop runs checkAllMintQuotes. CDK's mint_unissued_quotes + // issues proofs silently (drops amount_issued > 0 into the quote, + // excluding it from the unissued list), so if it ran first our + // recovery would find nothing and bolt11 metadata would be lost. + await _recoverPendingMintQuotes(); + // Iterar todos los mints y todas sus unidades, no solo los wallets // ya instanciados. initialize() solo precarga units.first por mint, // así que quotes/sagas/melts en otras unidades se perderían. @@ -1845,7 +1852,9 @@ class WalletProvider extends ChangeNotifier { final wallet = await getWallet(entry.key, unit); try { - // Reclamar quotes pagados pero no emitidos (Lightning → proofs) + // Safety net: after our recovery pass, this should be a no-op + // for healthy cases. Still useful if _recoverPendingMintQuotes + // errored on a specific quote and CDK can retry issuance. await wallet.checkAllMintQuotes(); } catch (e) { debugPrint('Check mint quotes failed: $e'); @@ -1878,9 +1887,6 @@ class WalletProvider extends ChangeNotifier { } } - // Recover paid-but-unissued quotes by quote_id (exact, no heuristics) - await _recoverPendingMintQuotes(); - // Resume pending Nostr payment request if app was killed mid-wait await resumePendingNostrRequest(); }