@@ -91,25 +91,21 @@ func (p *PsbtFundingRequired) Error() string {
9191}
9292
9393// AuxFundingDesc stores a series of attributes that may be used to modify the
94- // way the channel funding occurs
94+ // way the channel funding occurs. This struct contains information that can
95+ // only be derived once both sides have received and sent their contributions
96+ // to the channel (keys, etc).
9597type AuxFundingDesc struct {
9698 // CustomFundingBlob is a custom blob that'll be stored in the database
9799 // within the OpenChannel struct. This should represent information
98100 // static to the channel lifetime.
99101 CustomFundingBlob tlv.Blob
100102
101- // TapscriptRoot is the root of the tapscript tree that will be used to
102- // create the funding output.
103- TapscriptRoot chainhash.Hash
104-
105103 // CustomLocalCommitBlob is a custom blob that'll be stored in the
106104 // first commitment entry for the local party.
107105 CustomLocalCommitBlob tlv.Blob
108106
109107 // CustomRemoteCommitBlob is a custom blob that'll be stored in the
110108 // first commitment entry for the remote party.
111- //
112- // TODO(roasbeef): have this just use the leaf fetcher?
113109 CustomRemoteCommitBlob tlv.Blob
114110
115111 // InitAuxLeaves is the set of aux leaves that'll be used for the very
@@ -229,9 +225,9 @@ type InitFundingReserveMsg struct {
229225 // channel that will be useful to our future selves.
230226 Memo []byte
231227
232- // AuxFundingDesc is an optional descriptor that can be used to modify
233- // the way channel funding occurs .
234- AuxFundingDesc fn.Option [AuxFundingDesc ]
228+ // TapscriptRoot is an optional tapscript root that if provided, will
229+ // be used to create the combined key for musig2 based channels .
230+ TapscriptRoot fn.Option [chainhash. Hash ]
235231
236232 // err is a channel in which all errors will be sent across. Will be
237233 // nil if this initial set is successful.
@@ -268,7 +264,6 @@ type fundingReserveCancelMsg struct {
268264type addContributionMsg struct {
269265 pendingFundingID uint64
270266
271- // TODO(roasbeef): Should also carry SPV proofs in we're in SPV mode
272267 contribution * ChannelContribution
273268
274269 // NOTE: In order to avoid deadlocks, this channel MUST be buffered.
@@ -439,8 +434,6 @@ type LightningWallet struct {
439434 quit chan struct {}
440435
441436 wg sync.WaitGroup
442-
443- // TODO(roasbeef): handle wallet lock/unlock
444437}
445438
446439// NewLightningWallet creates/opens and initializes a LightningWallet instance.
@@ -485,7 +478,6 @@ func (l *LightningWallet) Startup() error {
485478 }
486479
487480 l .wg .Add (1 )
488- // TODO(roasbeef): multiple request handlers?
489481 go l .requestHandler ()
490482
491483 return nil
@@ -1439,7 +1431,6 @@ func (l *LightningWallet) initOurContribution(reservation *ChannelReservation,
14391431// transaction via coin selection are freed allowing future reservations to
14401432// include them.
14411433func (l * LightningWallet ) handleFundingCancelRequest (req * fundingReserveCancelMsg ) {
1442- // TODO(roasbeef): holding lock too long
14431434 l .limboMtx .Lock ()
14441435 defer l .limboMtx .Unlock ()
14451436
@@ -1461,11 +1452,6 @@ func (l *LightningWallet) handleFundingCancelRequest(req *fundingReserveCancelMs
14611452 l .UnlockOutpoint (unusedInput .PreviousOutPoint )
14621453 }
14631454
1464- // TODO(roasbeef): is it even worth it to keep track of unused keys?
1465-
1466- // TODO(roasbeef): Is it possible to mark the unused change also as
1467- // available?
1468-
14691455 delete (l .fundingLimbo , req .pendingFundingID )
14701456
14711457 pid := pendingReservation .pendingChanID
@@ -1638,16 +1624,24 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
16381624 // and remote key which will be needed to calculate the multisig
16391625 // funding output in a next step.
16401626 pendingChanID := pendingReservation .pendingChanID
1627+
16411628 walletLog .Debugf ("Advancing PSBT funding flow for " +
16421629 "pending_id(%x), binding keys local_key=%v, " +
16431630 "remote_key=%x" , pendingChanID ,
16441631 & ourContribution .MultiSigKey ,
16451632 theirContribution .MultiSigKey .PubKey .SerializeCompressed ())
1633+
16461634 fundingIntent .BindKeys (
16471635 & ourContribution .MultiSigKey ,
16481636 theirContribution .MultiSigKey .PubKey ,
16491637 )
16501638
1639+ // We might have a tapscript root, so we'll bind that now to
1640+ // ensure we make the proper funding output.
1641+ fundingIntent .BindTapscriptRoot (
1642+ pendingReservation .partialState .TapscriptRoot ,
1643+ )
1644+
16511645 // Exit early because we can't continue the funding flow yet.
16521646 req .err <- & PsbtFundingRequired {
16531647 Intent : fundingIntent ,
@@ -1720,16 +1714,17 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
17201714// the commitment transaction for the remote party, and verify their incoming
17211715// partial signature.
17221716func genMusigSession (ourContribution , theirContribution * ChannelContribution ,
1723- signer input.MuSig2Signer ,
1724- fundingOutput * wire. TxOut ) * MusigPairSession {
1717+ signer input.MuSig2Signer , fundingOutput * wire. TxOut ,
1718+ tapscriptRoot fn. Option [chainhash. Hash ] ) * MusigPairSession {
17251719
17261720 return NewMusigPairSession (& MusigSessionCfg {
1727- LocalKey : ourContribution .MultiSigKey ,
1728- RemoteKey : theirContribution .MultiSigKey ,
1729- LocalNonce : * ourContribution .LocalNonce ,
1730- RemoteNonce : * theirContribution .LocalNonce ,
1731- Signer : signer ,
1732- InputTxOut : fundingOutput ,
1721+ LocalKey : ourContribution .MultiSigKey ,
1722+ RemoteKey : theirContribution .MultiSigKey ,
1723+ LocalNonce : * ourContribution .LocalNonce ,
1724+ RemoteNonce : * theirContribution .LocalNonce ,
1725+ Signer : signer ,
1726+ InputTxOut : fundingOutput ,
1727+ TapscriptTweak : tapscriptRoot ,
17331728 })
17341729}
17351730
@@ -1779,6 +1774,7 @@ func (l *LightningWallet) signCommitTx(pendingReservation *ChannelReservation,
17791774 musigSessions := genMusigSession (
17801775 ourContribution , theirContribution ,
17811776 l .Cfg .Signer , fundingOutput ,
1777+ pendingReservation .partialState .TapscriptRoot ,
17821778 )
17831779 pendingReservation .musigSessions = musigSessions
17841780 }
@@ -2162,6 +2158,7 @@ func (l *LightningWallet) verifyCommitSig(res *ChannelReservation,
21622158 res .musigSessions = genMusigSession (
21632159 res .ourContribution , res .theirContribution ,
21642160 l .Cfg .Signer , fundingOutput ,
2161+ res .partialState .TapscriptRoot ,
21652162 )
21662163 }
21672164
@@ -2252,9 +2249,6 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
22522249
22532250 // As we're about to broadcast the funding transaction, we'll take note
22542251 // of the current height for record keeping purposes.
2255- //
2256- // TODO(roasbeef): this info can also be piped into light client's
2257- // basic fee estimation?
22582252 _ , bestHeight , err := l .Cfg .ChainIO .GetBestBlock ()
22592253 if err != nil {
22602254 msg .err <- err
0 commit comments