mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-10 21:04:53 +00:00
fix restoring lightning wallets
This commit is contained in:
parent
c2362461f1
commit
6218dcbcec
4 changed files with 11 additions and 5 deletions
|
@ -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,
|
||||
);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue