Compare commits

...
Author SHA1 Message Date
Forte11Cuba 9ab78e0ab8 fix: add startup recovery for lost proofs and pending operations 2026-03-20 11:32:16 -06:00
Forte11andGitHub d13b5e8782 Merge pull request #66 from Forte11Cuba/feature/nfc-support
feat: NFC support for Cashu token read/write
2026-03-13 17:34:47 -06:00
+38 -6
View File
@@ -1393,12 +1393,44 @@ class WalletProvider extends ChangeNotifier {
/// Llamar en background al iniciar la app.
/// También vincula transacciones incoming sin metadata con invoices pendientes.
Future<void> checkPendingTransactions() async {
for (final wallet in _wallets.values) {
try {
await wallet.checkPendingTransactions();
} catch (e) {
// Silencioso - puede fallar offline
debugPrint('Check pending failed: $e');
// 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.
for (final entry in _mintUnits.entries) {
for (final unit in entry.value) {
try {
final wallet = await getWallet(entry.key, unit);
try {
// Reclamar quotes pagados pero no emitidos (Lightning → proofs)
await wallet.checkAllMintQuotes();
} catch (e) {
debugPrint('Check mint quotes failed: $e');
}
try {
// Recuperar sagas incompletas (swaps/mints/melts interrumpidos)
await wallet.recoverIncompleteSagas();
} catch (e) {
debugPrint('Recover incomplete sagas failed: $e');
}
try {
// Finalizar retiros Lightning que quedaron a medias
await wallet.finalizePendingMelts();
} catch (e) {
debugPrint('Finalize pending melts failed: $e');
}
try {
await wallet.checkPendingTransactions();
} catch (e) {
// Silencioso - puede fallar offline
debugPrint('Check pending failed: $e');
}
} catch (e) {
debugPrint('Error getting wallet ${entry.key}:$unit: $e');
}
}
}