From c17590379e2b7007230d3937871a129a65e79125 Mon Sep 17 00:00:00 2001 From: Sangbida Chaudhuri <101164840+sangbida@users.noreply.github.com> Date: Tue, 13 Jan 2026 22:52:12 +1030 Subject: [PATCH] lightningd: use BIP86 derivation in p2wpkh_for_keyidx when available When a peer doesn't support OPT_SHUTDOWN_ANYSEGWIT, we fall back to P2WPKH for the shutdown script. For BIP86 wallets, we need to use bip86_pubkey for derivation (matching p2tr_for_keyidx), otherwise the resulting script won't be recognized after restart. --- lightningd/peer_control.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index ebc8cfa74..1e9dfa0d9 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -203,7 +203,12 @@ u8 *p2wpkh_for_keyidx(const tal_t *ctx, struct lightningd *ld, u64 keyidx) { struct pubkey shutdownkey; - bip32_pubkey(ld, &shutdownkey, keyidx); + /* Use BIP86 derivation if wallet has BIP86 base, otherwise use BIP32 */ + if (ld->bip86_base) { + bip86_pubkey(ld, &shutdownkey, keyidx); + } else { + bip32_pubkey(ld, &shutdownkey, keyidx); + } return scriptpubkey_p2wpkh(ctx, &shutdownkey); }