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] =
|
_balance[CryptoCurrency.btcln] =
|
||||||
initialBalance ?? LightningBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
|
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(
|
walletAddresses = BitcoinWalletAddresses(
|
||||||
walletInfo,
|
walletInfo,
|
||||||
electrumClient: electrumClient,
|
electrumClient: electrumClient,
|
||||||
initialAddresses: initialAddresses,
|
initialAddresses: initialAddresses,
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
mainHd: hd,
|
mainHd: hd.derivePath(derivationPath),
|
||||||
sideHd: bitcoin.HDWallet.fromSeed(seedBytes, network: networkType).derivePath("m/0'/1"),
|
sideHd: hd.derivePath(sideDerivationPath),
|
||||||
network: network,
|
network: network,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,8 @@ class WalletRestorePage extends BasePage {
|
||||||
|
|
||||||
// bip39:
|
// bip39:
|
||||||
const validSeedLengths = [12, 18, 24];
|
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))) {
|
!(validSeedLengths.contains(seedWords.length))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ abstract class WalletCreationVMBase with Store {
|
||||||
derivationType: DerivationType.nano,
|
derivationType: DerivationType.nano,
|
||||||
);
|
);
|
||||||
case WalletType.bitcoin:
|
case WalletType.bitcoin:
|
||||||
|
case WalletType.lightning:
|
||||||
case WalletType.litecoin:
|
case WalletType.litecoin:
|
||||||
return DerivationInfo(
|
return DerivationInfo(
|
||||||
derivationType: DerivationType.electrum,
|
derivationType: DerivationType.electrum,
|
||||||
|
@ -113,6 +114,7 @@ abstract class WalletCreationVMBase with Store {
|
||||||
derivationType: DerivationType.nano,
|
derivationType: DerivationType.nano,
|
||||||
);
|
);
|
||||||
case WalletType.bitcoin:
|
case WalletType.bitcoin:
|
||||||
|
case WalletType.lightning:
|
||||||
return DerivationInfo(
|
return DerivationInfo(
|
||||||
derivationType: DerivationType.bip39,
|
derivationType: DerivationType.bip39,
|
||||||
derivationPath: "m/84'/0'/0'/0",
|
derivationPath: "m/84'/0'/0'/0",
|
||||||
|
|
|
@ -104,8 +104,8 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||||
name: name,
|
name: name,
|
||||||
mnemonic: seed,
|
mnemonic: seed,
|
||||||
password: password,
|
password: password,
|
||||||
derivationPath: "",
|
derivationType: derivationInfo!.derivationType!,
|
||||||
derivationType: DerivationType.electrum,
|
derivationPath: derivationInfo.derivationPath!,
|
||||||
);
|
);
|
||||||
case WalletType.haven:
|
case WalletType.haven:
|
||||||
return haven!.createHavenRestoreWalletFromSeedCredentials(
|
return haven!.createHavenRestoreWalletFromSeedCredentials(
|
||||||
|
|
Loading…
Reference in a new issue