Cw 772 restore from qr generates different wallet (#1742)

* fix derivation info for QR restoring

* allow all available seed languages for Monero

* set default derivation info for an empty wallet

* fix electrum case
This commit is contained in:
Serhii 2024-10-16 20:25:22 +03:00 committed by GitHub
parent cb75f08b35
commit 605d164998
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 19 deletions

View file

@ -37,7 +37,8 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
spendKey = '', spendKey = '',
wif = '', wif = '',
address = '', address = '',
super(appStore, walletInfoSource, walletCreationService, seedSettingsViewModel, type: type, isRecovery: true); super(appStore, walletInfoSource, walletCreationService, seedSettingsViewModel,
type: type, isRecovery: true);
@observable @observable
int height; int height;
@ -112,7 +113,14 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
); );
case WalletType.bitcoin: case WalletType.bitcoin:
case WalletType.litecoin: 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( return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials(
name: name, name: name,
mnemonic: restoreWallet.mnemonicSeed ?? '', mnemonic: restoreWallet.mnemonicSeed ?? '',

View file

@ -194,24 +194,31 @@ abstract class WalletCreationVMBase with Store {
final walletType = restoreWallet.type; final walletType = restoreWallet.type;
var appStore = getIt.get<AppStore>(); var appStore = getIt.get<AppStore>();
var node = appStore.settingsStore.getCurrentNode(walletType); var node = appStore.settingsStore.getCurrentNode(walletType);
switch (walletType) {
case WalletType.bitcoin:
case WalletType.litecoin:
switch (walletType) { final derivationList = await bitcoin!.getDerivationsFromMnemonic(
case WalletType.bitcoin: mnemonic: restoreWallet.mnemonicSeed!,
case WalletType.litecoin: node: node,
return bitcoin!.getDerivationsFromMnemonic( passphrase: restoreWallet.passphrase,
mnemonic: restoreWallet.mnemonicSeed!, );
node: node,
passphrase: restoreWallet.passphrase,
); if (derivationList.first.transactionsCount == 0 && derivationList.length > 1) return [];
case WalletType.nano:
return nanoUtil!.getDerivationsFromMnemonic( return derivationList;
mnemonic: restoreWallet.mnemonicSeed!,
node: node, case WalletType.nano:
); return nanoUtil!.getDerivationsFromMnemonic(
default: mnemonic: restoreWallet.mnemonicSeed!,
break; node: node,
} );
return list; default:
break;
}
return list;
} }
WalletCredentials getCredentials(dynamic options) => throw UnimplementedError(); WalletCredentials getCredentials(dynamic options) => throw UnimplementedError();