diff --git a/lib/services/wallets_service.dart b/lib/services/wallets_service.dart index 085937ca6..cbba6bf5a 100644 --- a/lib/services/wallets_service.dart +++ b/lib/services/wallets_service.dart @@ -140,6 +140,29 @@ class WalletsService extends ChangeNotifier { name, WalletInfo.fromJson(Map.from(dyn as Map)))); } + Map fetchWalletsData() { + final names = DB.instance.get( + boxName: DB.boxNameAllWalletsData, key: 'names') as Map? ?? + {}; + + Logging.instance.log("Fetched wallet names: $names", level: LogLevel.Info); + final mapped = Map.from(names); + mapped.removeWhere((name, dyn) { + final jsonObject = Map.from(dyn as Map); + try { + Coin.values.byName(jsonObject["coin"] as String); + return false; + } catch (e, s) { + Logging.instance.log("Error, ${jsonObject["coin"]} does not exist", + level: LogLevel.Error); + return true; + } + }); + + return mapped.map((name, dyn) => MapEntry( + name, WalletInfo.fromJson(Map.from(dyn as Map)))); + } + Future addExistingStackWallet({ required String name, required String walletId,