litecoin fixes

This commit is contained in:
Matthew Fosse 2024-04-29 14:39:14 -07:00
parent 4052d7edd5
commit a008c1f2dd
2 changed files with 38 additions and 35 deletions

View file

@ -64,7 +64,7 @@ Map<DerivationType, List<DerivationInfo>> bitcoin_derivations = {
description: "Samourai Deposit", description: "Samourai Deposit",
scriptType: "p2wpkh", scriptType: "p2wpkh",
), ),
DerivationInfo( DerivationInfo(
derivationType: DerivationType.bip39, derivationType: DerivationType.bip39,
derivationPath: "m/84'/0'/0'", derivationPath: "m/84'/0'/0'",
description: "Samourai Deposit", description: "Samourai Deposit",
@ -106,5 +106,11 @@ Map<DerivationType, List<DerivationInfo>> bitcoin_derivations = {
description: "Samourai Ricochet native segwit", description: "Samourai Ricochet native segwit",
scriptType: "p2wpkh", scriptType: "p2wpkh",
), ),
DerivationInfo(
derivationType: DerivationType.bip39,
derivationPath: "m/84'/2'/0'",
description: "Default Litecoin",
scriptType: "p2wpkh",
),
], ],
}; };

View file

@ -355,50 +355,47 @@ class WalletRestorePage extends BasePage {
walletRestoreViewModel.state = IsExecutingState(); walletRestoreViewModel.state = IsExecutingState();
List<DerivationType> derivationTypes =
await walletRestoreViewModel.getDerivationTypes(_credentials());
DerivationInfo? dInfo; DerivationInfo? dInfo;
if (derivationTypes.length > 1) { // get info about the different derivations:
// push screen to choose the derivation type: List<DerivationInfo> derivations =
List<DerivationInfo> derivations = await walletRestoreViewModel.getDerivationInfo(_credentials());
await walletRestoreViewModel.getDerivationInfo(_credentials());
int derivationsWithHistory = 0; int derivationsWithHistory = 0;
int derivationWithHistoryIndex = 0; int derivationWithHistoryIndex = 0;
for (int i = 0; i < derivations.length; i++) { for (int i = 0; i < derivations.length; i++) {
if (derivations[i].transactionsCount > 0) { if (derivations[i].transactionsCount > 0) {
derivationsWithHistory++; derivationsWithHistory++;
derivationWithHistoryIndex = i; derivationWithHistoryIndex = i;
}
} }
}
// dInfo = await Navigator.of(context).pushNamed(Routes.restoreWalletChooseDerivation, if (derivationsWithHistory > 1) {
// arguments: derivations) as DerivationInfo?; dInfo = await Navigator.of(context).pushNamed(
Routes.restoreWalletChooseDerivation,
if (derivationsWithHistory > 1) { arguments: derivations,
dInfo = await Navigator.of(context).pushNamed(Routes.restoreWalletChooseDerivation, ) as DerivationInfo?;
arguments: derivations) as DerivationInfo?; } else if (derivationsWithHistory == 1) {
} else if (derivationsWithHistory == 1) { dInfo = derivations[derivationWithHistoryIndex];
dInfo = derivations[derivationWithHistoryIndex];
} else {
dInfo = walletRestoreViewModel.getCommonRestoreDerivation();
}
if (dInfo == null) {
walletRestoreViewModel.state = InitialExecutionState();
return;
}
this.derivationInfo = dInfo;
} }
// get the default derivation for this wallet type: // get the default derivation for this wallet type:
if (this.derivationInfo == null) { if (dInfo == null) {
this.derivationInfo = walletRestoreViewModel.getDefaultDerivation(); // we only return 1 derivation if we're pretty sure we know which one to use:
if (derivations.length == 1) {
dInfo = derivations.first;
} else {
// if we have multiple possible derivations, and none have histories
// we just default to the most common one:
dInfo = walletRestoreViewModel.getCommonRestoreDerivation();
}
} }
walletRestoreViewModel.state = InitialExecutionState(); this.derivationInfo = dInfo;
if (this.derivationInfo == null) {
walletRestoreViewModel.state = InitialExecutionState();
return;
}
walletRestoreViewModel.create(options: _credentials()); walletRestoreViewModel.create(options: _credentials());
} }