Skip to content

Commit 54f4ceb

Browse files
sangbidarustyrussell
authored andcommitted
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.
1 parent e43c79d commit 54f4ceb

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lightningd/peer_control.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ u8 *p2wpkh_for_keyidx(const tal_t *ctx, struct lightningd *ld, u64 keyidx)
203203
{
204204
struct pubkey shutdownkey;
205205

206-
bip32_pubkey(ld, &shutdownkey, keyidx);
206+
/* Use BIP86 derivation if wallet has BIP86 base, otherwise use BIP32 */
207+
if (ld->bip86_base) {
208+
bip86_pubkey(ld, &shutdownkey, keyidx);
209+
} else {
210+
bip32_pubkey(ld, &shutdownkey, keyidx);
211+
}
207212
return scriptpubkey_p2wpkh(ctx, &shutdownkey);
208213
}
209214

0 commit comments

Comments
 (0)