fix restoring lightning wallets

This commit is contained in:
Matthew Fosse 2024-05-03 11:37:23 -07:00
parent c2362461f1
commit 6218dcbcec
4 changed files with 11 additions and 5 deletions

View file

@ -65,14 +65,17 @@ abstract class LightningWalletBase extends ElectrumWallet with Store {
) {
_balance[CryptoCurrency.btcln] =
initialBalance ?? LightningBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
String derivationPath = walletInfo.derivationInfo!.derivationPath!;
String sideDerivationPath = derivationPath.substring(0, derivationPath.length - 1) + "1";
final hd = bitcoin.HDWallet.fromSeed(seedBytes, network: networkType);
walletAddresses = BitcoinWalletAddresses(
walletInfo,
electrumClient: electrumClient,
initialAddresses: initialAddresses,
initialRegularAddressIndex: initialRegularAddressIndex,
initialChangeAddressIndex: initialChangeAddressIndex,
mainHd: hd,
sideHd: bitcoin.HDWallet.fromSeed(seedBytes, network: networkType).derivePath("m/0'/1"),
mainHd: hd.derivePath(derivationPath),
sideHd: hd.derivePath(sideDerivationPath),
network: network,
);

View file

@ -264,7 +264,8 @@ class WalletRestorePage extends BasePage {
// bip39:
const validSeedLengths = [12, 18, 24];
if (walletRestoreViewModel.type == WalletType.bitcoin &&
final type = walletRestoreViewModel.type;
if ((type == WalletType.bitcoin || type == WalletType.lightning) &&
!(validSeedLengths.contains(seedWords.length))) {
return false;
}

View file

@ -96,6 +96,7 @@ abstract class WalletCreationVMBase with Store {
derivationType: DerivationType.nano,
);
case WalletType.bitcoin:
case WalletType.lightning:
case WalletType.litecoin:
return DerivationInfo(
derivationType: DerivationType.electrum,
@ -113,6 +114,7 @@ abstract class WalletCreationVMBase with Store {
derivationType: DerivationType.nano,
);
case WalletType.bitcoin:
case WalletType.lightning:
return DerivationInfo(
derivationType: DerivationType.bip39,
derivationPath: "m/84'/0'/0'/0",

View file

@ -104,8 +104,8 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
name: name,
mnemonic: seed,
password: password,
derivationPath: "",
derivationType: DerivationType.electrum,
derivationType: derivationInfo!.derivationType!,
derivationPath: derivationInfo.derivationPath!,
);
case WalletType.haven:
return haven!.createHavenRestoreWalletFromSeedCredentials(