@@ -224,9 +224,12 @@ func WithTapscriptRoot(root chainhash.Hash) FundingScriptOpt {
224224}
225225
226226// GenTaprootFundingScript constructs the taproot-native funding output that
227- // uses musig2 to create a single aggregated key to anchor the channel.
228- func GenTaprootFundingScript (aPub , bPub * btcec.PublicKey ,
229- amt int64 , opts ... FundingScriptOpt ) ([]byte , * wire.TxOut , error ) {
227+ // uses musig2 to create a single aggregated key to anchor the channel. This
228+ // also returns the musig2 aggregated key to allow the callers to examine the
229+ // pre tweaked key as well as the final combined key.
230+ func GenTaprootFundingScript (aPub , bPub * btcec.PublicKey , amt int64 ,
231+ opts ... FundingScriptOpt ) ([]byte , * wire.TxOut ,
232+ * musig2.AggregateKey , error ) {
230233
231234 options := defaultFundingScriptOpts ()
232235 for _ , optFunc := range opts {
@@ -248,22 +251,23 @@ func GenTaprootFundingScript(aPub, bPub *btcec.PublicKey,
248251 []* btcec.PublicKey {aPub , bPub }, true , musig2Opts ,
249252 )
250253 if err != nil {
251- return nil , nil , fmt .Errorf ("unable to combine keys: %w" , err )
254+ return nil , nil , nil , fmt .Errorf ("unable to combine " +
255+ "keys: %w" , err )
252256 }
253257
254258 // Now that we have the combined key, we can create a taproot pkScript
255259 // from this, and then make the txout given the amount.
256260 pkScript , err := PayToTaprootScript (combinedKey .FinalKey )
257261 if err != nil {
258- return nil , nil , fmt .Errorf ("unable to make taproot " +
262+ return nil , nil , nil , fmt .Errorf ("unable to make taproot " +
259263 "pkscript: %w" , err )
260264 }
261265
262266 txOut := wire .NewTxOut (amt , pkScript )
263267
264268 // For the "witness program" we just return the raw pkScript since the
265269 // output we create can _only_ be spent with a musig2 signature.
266- return pkScript , txOut , nil
270+ return pkScript , txOut , combinedKey , nil
267271}
268272
269273// SpendMultiSig generates the witness stack required to redeem the 2-of-2 p2wsh
0 commit comments