diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart index 757868e9a..301830004 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart @@ -42,7 +42,9 @@ import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; +import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; import 'package:stackwallet/wallets/wallet/wallet.dart'; +import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart'; import 'package:tuple/tuple.dart'; @@ -422,6 +424,12 @@ abstract class SWB { restoreHeight = walletbackup['storedChainHeight'] as int? ?? 0; } + Future? restoringFuture; + + if (!(wallet is CwBasedInterface || wallet is EpiccashWallet)) { + restoringFuture = wallet.recover(isRescan: false); + } + uiState?.update( walletId: info.walletId, restoringStatus: StackRestoringStatus.restoring, @@ -466,6 +474,8 @@ abstract class SWB { return false; } + await restoringFuture; + Logging.instance.log( "SWB restored: ${info.walletId} ${info.name} ${info.coin.prettyName}", level: LogLevel.Info); @@ -690,13 +700,34 @@ abstract class SWB { // TODO: use these for monero and possibly other coins later on? // final List txidList = List.from(walletbackup['txidList'] as List? ?? []); + Map? otherData; + try { + if (walletbackup["otherDataJsonString"] is String) { + final data = + jsonDecode(walletbackup["otherDataJsonString"] as String); + otherData = Map.from(data as Map); + } + } catch (e, s) { + Logging.instance.log( + "SWB restore walletinfo otherdata error: $e\n$s", + level: LogLevel.Error, + ); + } + + if (coin == Coin.firo) { + otherData ??= {}; + // swb will do a restore so this flag should be set to false so another + // rescan/restore isn't done when opening the wallet + otherData[WalletInfoKeys.lelantusCoinIsarRescanRequired] = false; + } + final info = WalletInfo( coinName: coin.name, walletId: walletId, name: walletName, mainAddressType: coin.primaryAddressType, restoreHeight: walletbackup['restoreHeight'] as int? ?? 0, - otherDataJsonString: walletbackup["otherDataJsonString"] as String?, + otherDataJsonString: otherData == null ? null : jsonEncode(otherData), cachedChainHeight: walletbackup['storedChainHeight'] as int? ?? 0, ); diff --git a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart index b352693ee..194b8df10 100644 --- a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart +++ b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart @@ -40,7 +40,7 @@ class WalletListItem extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - debugPrint("BUILD: $runtimeType"); + // debugPrint("BUILD: $runtimeType"); final walletCountString = walletCount == 1 ? "$walletCount wallet" : "$walletCount wallets"; final currency = ref