From c574a7e41d94337432d8aa5c33fd8278a335051e Mon Sep 17 00:00:00 2001
From: vjrj <vjrj@comunes.org>
Date: Sun, 12 Nov 2023 22:42:00 +0100
Subject: [PATCH] Reset consumed utxos

---
 lib/data/models/utxo_cubit.dart | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/data/models/utxo_cubit.dart b/lib/data/models/utxo_cubit.dart
index 3ca4c969..0e246ceb 100644
--- a/lib/data/models/utxo_cubit.dart
+++ b/lib/data/models/utxo_cubit.dart
@@ -101,10 +101,8 @@ class UtxoCubit extends HydratedCubit<UtxoState> {
         return null;
       }
 
-      // Emit a new state
       emit(currentState.copyWith(
         consumedUtxos: updatedConsumedUtxos,
-        // Update other fields if necessary
       ));
       return selectedUtxos;
     } else {
@@ -112,4 +110,13 @@ class UtxoCubit extends HydratedCubit<UtxoState> {
       return null;
     }
   }
+
+  void resetConsumedUtxos() {
+    if (state is UtxoLoaded) {
+      // Emit a new state with an empty map for consumed UTXOs
+      emit((state as UtxoLoaded).copyWith(consumedUtxos: <String, Utxo>{}));
+    } else {
+      emit(UtxosError('Wrong utxo state'));
+    }
+  }
 }
-- 
GitLab