This commit is contained in:
fossephate 2023-09-01 09:22:55 -04:00
parent 287f3e06f7
commit 30c870b726
2 changed files with 22 additions and 1 deletions

View file

@ -114,6 +114,10 @@ class BitcoinWalletService extends WalletService<BitcoinNewWalletCredentials,
static Future<List<DerivationType>> compareDerivationMethods(
{required String mnemonic, required Node node}) async {
if (!validateMnemonic(mnemonic)) {
throw BitcoinMnemonicIsIncorrectException();
}
if (await checkIfMnemonicIsElectrum2(mnemonic)) {
return [DerivationType.electrum2];
}

View file

@ -30,8 +30,25 @@ abstract class WalletRestoreChooseDerivationViewModelBase with Store {
switch (walletType) {
case WalletType.bitcoin:
String? mnemonic = credentials['seed'] as String?;
return await BitcoinWalletService.getDerivationsFromMnemonic(mnemonic: mnemonic!, node: node);
var derivations = await BitcoinWalletService.getDerivationsFromMnemonic(mnemonic: mnemonic!, node: node);
int count = 0;
for (int i = 0; i < derivations.length; i++) {
if (derivations[i].height != 0) {
count += 1;
}
}
if (count == 1) {
for (int i = 0; i < derivations.length; i++) {
if (derivations[i].height != 0) {
list.add(derivations[i]);
}
}
} else {
return derivations;
}
// var standardInfo = await NanoWalletService.getInfoFromSeedOrMnemonic(
// DerivationType.nano,
// mnemonic: mnemonic,