diff --git a/cw_lightning/lib/lightning_wallet.dart b/cw_lightning/lib/lightning_wallet.dart index 1547be95c..1f1e3a0ef 100644 --- a/cw_lightning/lib/lightning_wallet.dart +++ b/cw_lightning/lib/lightning_wallet.dart @@ -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, ); diff --git a/lib/src/screens/restore/wallet_restore_page.dart b/lib/src/screens/restore/wallet_restore_page.dart index 6fcacfb0a..422acad4a 100644 --- a/lib/src/screens/restore/wallet_restore_page.dart +++ b/lib/src/screens/restore/wallet_restore_page.dart @@ -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; } diff --git a/lib/view_model/wallet_creation_vm.dart b/lib/view_model/wallet_creation_vm.dart index 5c9c29a16..44eed0f18 100644 --- a/lib/view_model/wallet_creation_vm.dart +++ b/lib/view_model/wallet_creation_vm.dart @@ -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", diff --git a/lib/view_model/wallet_restore_view_model.dart b/lib/view_model/wallet_restore_view_model.dart index 67d849602..8b577ce50 100644 --- a/lib/view_model/wallet_restore_view_model.dart +++ b/lib/view_model/wallet_restore_view_model.dart @@ -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(