mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
various swb fixes
This commit is contained in:
parent
f319aaf594
commit
aaa6905f95
2 changed files with 33 additions and 2 deletions
|
@ -42,7 +42,9 @@ import 'package:stackwallet/utilities/logger.dart';
|
||||||
import 'package:stackwallet/utilities/prefs.dart';
|
import 'package:stackwallet/utilities/prefs.dart';
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
import 'package:stackwallet/wallets/isar/models/wallet_info.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.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/mnemonic_interface.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart';
|
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
@ -422,6 +424,12 @@ abstract class SWB {
|
||||||
restoreHeight = walletbackup['storedChainHeight'] as int? ?? 0;
|
restoreHeight = walletbackup['storedChainHeight'] as int? ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void>? restoringFuture;
|
||||||
|
|
||||||
|
if (!(wallet is CwBasedInterface || wallet is EpiccashWallet)) {
|
||||||
|
restoringFuture = wallet.recover(isRescan: false);
|
||||||
|
}
|
||||||
|
|
||||||
uiState?.update(
|
uiState?.update(
|
||||||
walletId: info.walletId,
|
walletId: info.walletId,
|
||||||
restoringStatus: StackRestoringStatus.restoring,
|
restoringStatus: StackRestoringStatus.restoring,
|
||||||
|
@ -466,6 +474,8 @@ abstract class SWB {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await restoringFuture;
|
||||||
|
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"SWB restored: ${info.walletId} ${info.name} ${info.coin.prettyName}",
|
"SWB restored: ${info.walletId} ${info.name} ${info.coin.prettyName}",
|
||||||
level: LogLevel.Info);
|
level: LogLevel.Info);
|
||||||
|
@ -690,13 +700,34 @@ abstract class SWB {
|
||||||
// TODO: use these for monero and possibly other coins later on?
|
// TODO: use these for monero and possibly other coins later on?
|
||||||
// final List<String> txidList = List<String>.from(walletbackup['txidList'] as List? ?? []);
|
// final List<String> txidList = List<String>.from(walletbackup['txidList'] as List? ?? []);
|
||||||
|
|
||||||
|
Map<String, dynamic>? otherData;
|
||||||
|
try {
|
||||||
|
if (walletbackup["otherDataJsonString"] is String) {
|
||||||
|
final data =
|
||||||
|
jsonDecode(walletbackup["otherDataJsonString"] as String);
|
||||||
|
otherData = Map<String, dynamic>.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(
|
final info = WalletInfo(
|
||||||
coinName: coin.name,
|
coinName: coin.name,
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
name: walletName,
|
name: walletName,
|
||||||
mainAddressType: coin.primaryAddressType,
|
mainAddressType: coin.primaryAddressType,
|
||||||
restoreHeight: walletbackup['restoreHeight'] as int? ?? 0,
|
restoreHeight: walletbackup['restoreHeight'] as int? ?? 0,
|
||||||
otherDataJsonString: walletbackup["otherDataJsonString"] as String?,
|
otherDataJsonString: otherData == null ? null : jsonEncode(otherData),
|
||||||
cachedChainHeight: walletbackup['storedChainHeight'] as int? ?? 0,
|
cachedChainHeight: walletbackup['storedChainHeight'] as int? ?? 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class WalletListItem extends ConsumerWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
debugPrint("BUILD: $runtimeType");
|
// debugPrint("BUILD: $runtimeType");
|
||||||
final walletCountString =
|
final walletCountString =
|
||||||
walletCount == 1 ? "$walletCount wallet" : "$walletCount wallets";
|
walletCount == 1 ? "$walletCount wallet" : "$walletCount wallets";
|
||||||
final currency = ref
|
final currency = ref
|
||||||
|
|
Loading…
Reference in a new issue