From 52b122a8bbb4be8fdc0a267bf378d650cca81fed Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 1 Mar 2023 21:44:14 -0800 Subject: [PATCH] lnwallet: NewUnilateralCloseSummary for local taproot output sweep --- lnwallet/channel.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 6f5fd9fc3..e229c25e1 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -6372,6 +6372,26 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, signer input.Si }, MaturityDelay: maturityDelay, } + + // For taproot channels, we'll need to set some additional + // fields to ensure the output can be swept. + // + // TODO(roasbef): abstract into new func + if chanState.ChanType.IsTaproot() { + commitResolution.SelfOutputSignDesc.SignMethod = + input.TaprootScriptSpendSignMethod + + ctrlBlock := input.MakeTaprootCtrlBlock( + commitResolution.SelfOutputSignDesc.WitnessScript, + &input.TaprootNUMSKey, selfScript.ScriptTree, + ) + commitResolution.SelfOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes() + if err != nil { + return nil, err + } + + // TODO(roasbeef): put ctrl block in resolution? + } } closeSummary := channeldb.ChannelCloseSummary{