lnwallet/chanfunding: add optional tapscript root

This commit is contained in:
Olaoluwa Osuntokun 2024-03-13 10:47:12 -04:00 committed by Oliver Gugger
parent 2c56b3120a
commit eeee2979e5
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
3 changed files with 11 additions and 2 deletions

View File

@ -58,6 +58,14 @@ type ShimIntent struct {
// generate an aggregate key to use as the taproot-native multi-sig
// output.
musig2 bool
// tapscriptRoot is the root of the tapscript tree that will be used to
// create the funding output. This field will only be utilized if the
// MuSig2 flag above is set to true.
//
// TODO(roasbeef): fold above into new chan type? sum type like thing,
// includes the tapscript root, etc
tapscriptRoot fn.Option[chainhash.Hash]
}
// FundingOutput returns the witness script, and the output that creates the
@ -79,7 +87,7 @@ func (s *ShimIntent) FundingOutput() ([]byte, *wire.TxOut, error) {
// the keys are sorted before use.
return input.GenTaprootFundingScript(
s.localKey.PubKey, s.remoteKey, int64(totalAmt),
fn.None[chainhash.Hash](),
s.tapscriptRoot,
)
}

View File

@ -534,6 +534,7 @@ func (p *PsbtAssembler) ProvisionChannel(req *Request) (Intent, error) {
ShimIntent: ShimIntent{
localFundingAmt: p.fundingAmt,
musig2: req.Musig2,
tapscriptRoot: req.TapscriptRoot,
},
State: PsbtShimRegistered,
BasePsbt: p.basePsbt,

View File

@ -394,7 +394,6 @@ func (w *WalletAssembler) ProvisionChannel(r *Request) (Intent, error) {
// we will call the specialized coin selection function for
// that.
case r.FundUpToMaxAmt != 0 && r.MinFundAmt != 0:
// We need to ensure that manually selected coins, which
// are spent entirely on the channel funding, leave
// enough funds in the wallet to cover for a reserve.
@ -539,6 +538,7 @@ func (w *WalletAssembler) ProvisionChannel(r *Request) (Intent, error) {
localFundingAmt: localContributionAmt,
remoteFundingAmt: r.RemoteAmt,
musig2: r.Musig2,
tapscriptRoot: r.TapscriptRoot,
},
InputCoins: selectedCoins,
coinLeaser: w.cfg.CoinLeaser,