Skip to content

Commit 8a69b67

Browse files
committed
lnwallet: add TaprootInternalKey method to ShimIntent
If this is a taproot channel, then we'll return the internal key which'll be useful to callers.
1 parent b0f643d commit 8a69b67

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lnwallet/chanfunding/canned_assembler.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,34 @@ func (s *ShimIntent) FundingOutput() ([]byte, *wire.TxOut, error) {
107107
)
108108
}
109109

110+
// TaprootInternalKey may return the internal key for a musig2 funding output,
111+
// but only if this is actually a musig2 channel.
112+
func (s *ShimIntent) TaprootInternalKey() fn.Option[*btcec.PublicKey] {
113+
if !s.musig2 {
114+
return fn.None[*btcec.PublicKey]()
115+
}
116+
117+
// TODO(roasbeef): refactor
118+
119+
var scriptOpts []input.FundingScriptOpt
120+
s.tapscriptRoot.WhenSome(func(root chainhash.Hash) {
121+
scriptOpts = append(
122+
scriptOpts, input.WithTapscriptRoot(root),
123+
)
124+
})
125+
126+
// Similar to the existing p2wsh script, we'll always ensure the keys
127+
// are sorted before use.
128+
//
129+
// We ignore the eror here as this is only called afterr FundingOutput
130+
// is called.
131+
_, _, musig2Key, _ := input.GenTaprootFundingScript(
132+
s.localKey.PubKey, s.remoteKey, 0, scriptOpts...,
133+
)
134+
135+
return fn.Some(musig2Key.PreTweakedKey)
136+
}
137+
110138
// Cancel allows the caller to cancel a funding Intent at any time. This will
111139
// return any resources such as coins back to the eligible pool to be used in
112140
// order channel fundings.

0 commit comments

Comments
 (0)