Skip to content

Commit 8e40047

Browse files
committed
Fixing funding wallet derivation
1 parent db28c14 commit 8e40047

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/bin/lnpd.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn main() -> Result<(), Error> {
7272

7373
fn init(config: &Config) -> Result<(), Error> {
7474
use bitcoin::secp256k1::Secp256k1;
75-
use bitcoin::util::bip32::{DerivationPath, ExtendedPrivKey};
75+
use bitcoin::util::bip32::{ChildNumber, DerivationPath, ExtendedPrivKey};
7676
use bitcoin_hd::{
7777
SegmentIndexes, TerminalStep, TrackingAccount, UnhardenedIndex,
7878
};
@@ -154,11 +154,23 @@ fn init(config: &Config) -> Result<(), Error> {
154154
LNP_NODE_FUNDING_WALLET,
155155
"creating".action()
156156
);
157+
let account_path = &[10046_u16, 0, 2][..];
158+
let node_xpriv = signing_account.account_xpriv();
159+
let account_xpriv = node_xpriv.derive_priv(
160+
&secp,
161+
&account_path
162+
.iter()
163+
.copied()
164+
.map(u32::from)
165+
.map(ChildNumber::from_hardened_idx)
166+
.collect::<Result<Vec<_>, _>>()
167+
.expect("hardcoded derivation indexes"),
168+
)?;
157169
let account = TrackingAccount::with(
158170
&secp,
159171
*signing_account.master_id(),
160-
*signing_account.account_xpriv(),
161-
&[10046, 0, 2],
172+
account_xpriv,
173+
account_path,
162174
vec![TerminalStep::range(0u16, 1u16), TerminalStep::Wildcard],
163175
);
164176
let wallet_data = WalletData {

0 commit comments

Comments
 (0)