diff --git a/lib/view_model/restore/restore_from_qr_vm.dart b/lib/view_model/restore/restore_from_qr_vm.dart index 042a048d9..cbdad85b8 100644 --- a/lib/view_model/restore/restore_from_qr_vm.dart +++ b/lib/view_model/restore/restore_from_qr_vm.dart @@ -37,7 +37,8 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store spendKey = '', wif = '', address = '', - super(appStore, walletInfoSource, walletCreationService, seedSettingsViewModel, type: type, isRecovery: true); + super(appStore, walletInfoSource, walletCreationService, seedSettingsViewModel, + type: type, isRecovery: true); @observable int height; @@ -112,7 +113,14 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store ); case WalletType.bitcoin: case WalletType.litecoin: - final derivationInfo = (await getDerivationInfoFromQRCredentials(restoreWallet)).first; + + final derivationInfoList = await getDerivationInfoFromQRCredentials(restoreWallet); + DerivationInfo derivationInfo; + if (derivationInfoList.isEmpty) { + derivationInfo = getDefaultCreateDerivation()!; + } else { + derivationInfo = derivationInfoList.first; + } return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials( name: name, mnemonic: restoreWallet.mnemonicSeed ?? '', diff --git a/lib/view_model/wallet_creation_vm.dart b/lib/view_model/wallet_creation_vm.dart index f31f879a1..90b4c5c3a 100644 --- a/lib/view_model/wallet_creation_vm.dart +++ b/lib/view_model/wallet_creation_vm.dart @@ -194,24 +194,31 @@ abstract class WalletCreationVMBase with Store { final walletType = restoreWallet.type; var appStore = getIt.get(); var node = appStore.settingsStore.getCurrentNode(walletType); + + switch (walletType) { + case WalletType.bitcoin: + case WalletType.litecoin: - switch (walletType) { - case WalletType.bitcoin: - case WalletType.litecoin: - return bitcoin!.getDerivationsFromMnemonic( - mnemonic: restoreWallet.mnemonicSeed!, - node: node, - passphrase: restoreWallet.passphrase, - ); - case WalletType.nano: - return nanoUtil!.getDerivationsFromMnemonic( - mnemonic: restoreWallet.mnemonicSeed!, - node: node, - ); - default: - break; - } - return list; + final derivationList = await bitcoin!.getDerivationsFromMnemonic( + mnemonic: restoreWallet.mnemonicSeed!, + node: node, + passphrase: restoreWallet.passphrase, + ); + + + if (derivationList.first.transactionsCount == 0 && derivationList.length > 1) return []; + + return derivationList; + + case WalletType.nano: + return nanoUtil!.getDerivationsFromMnemonic( + mnemonic: restoreWallet.mnemonicSeed!, + node: node, + ); + default: + break; + } + return list; } WalletCredentials getCredentials(dynamic options) => throw UnimplementedError();