diff --git a/lib/src/screens/restore/wallet_restore_page.dart b/lib/src/screens/restore/wallet_restore_page.dart index 415ae1e90..ac24d92de 100644 --- a/lib/src/screens/restore/wallet_restore_page.dart +++ b/lib/src/screens/restore/wallet_restore_page.dart @@ -377,8 +377,6 @@ class WalletRestorePage extends BasePage { ) as DerivationInfo?; } else if (derivationsWithHistory == 1) { dInfo = derivations[derivationWithHistoryIndex]; - } else if (derivationsWithHistory == 0 && derivations.isNotEmpty) { - dInfo = derivations.first; } if (dInfo == null) { @@ -390,7 +388,7 @@ class WalletRestorePage extends BasePage { // get the default derivation for this wallet type: if (this.derivationInfo == null) { - this.derivationInfo = walletRestoreViewModel.getDefaultDerivation(); + this.derivationInfo = walletRestoreViewModel.getMostCommonDerivation(); } walletRestoreViewModel.state = InitialExecutionState(); diff --git a/lib/view_model/restore/restore_from_qr_vm.dart b/lib/view_model/restore/restore_from_qr_vm.dart index b9b493f04..808621183 100644 --- a/lib/view_model/restore/restore_from_qr_vm.dart +++ b/lib/view_model/restore/restore_from_qr_vm.dart @@ -59,7 +59,7 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store derivationInfo = options["derivationInfo"] as DerivationInfo?; passphrase = options["passphrase"] as String?; } - derivationInfo ??= getDefaultDerivation(); + derivationInfo ??= getDefaultCreationDerivation(); switch (restoreWallet.restoreMode) { case WalletRestoreMode.keys: diff --git a/lib/view_model/wallet_creation_vm.dart b/lib/view_model/wallet_creation_vm.dart index a7baf4ffd..87666a298 100644 --- a/lib/view_model/wallet_creation_vm.dart +++ b/lib/view_model/wallet_creation_vm.dart @@ -71,7 +71,7 @@ abstract class WalletCreationVMBase with Store { dirPath: dirPath, address: '', showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven, - derivationInfo: credentials.derivationInfo ?? getDefaultDerivation(), + derivationInfo: credentials.derivationInfo ?? getDefaultCreationDerivation(), ); credentials.walletInfo = walletInfo; @@ -89,7 +89,7 @@ abstract class WalletCreationVMBase with Store { } } - DerivationInfo? getDefaultDerivation() { + DerivationInfo? getDefaultCreationDerivation() { switch (this.type) { case WalletType.nano: return DerivationInfo( @@ -106,6 +106,23 @@ abstract class WalletCreationVMBase with Store { } } + DerivationInfo? getMostCommonDerivation() { + switch (this.type) { + case WalletType.nano: + return DerivationInfo( + derivationType: DerivationType.nano, + ); + case WalletType.bitcoin: + case WalletType.litecoin: + return DerivationInfo( + derivationType: DerivationType.electrum, + derivationPath: "m/84'/0'/0'/0", + ); + default: + return null; + } + } + WalletCredentials getCredentials(dynamic options) => throw UnimplementedError(); Future process(WalletCredentials credentials) => throw UnimplementedError();