@@ -282,6 +282,8 @@ type addContributionMsg struct {
282282type continueContributionMsg struct {
283283 pendingFundingID uint64
284284
285+ auxFundingDesc fn.Option [AuxFundingDesc ]
286+
285287 // NOTE: In order to avoid deadlocks, this channel MUST be buffered.
286288 err chan error
287289}
@@ -337,6 +339,8 @@ type addCounterPartySigsMsg struct {
337339type addSingleFunderSigsMsg struct {
338340 pendingFundingID uint64
339341
342+ auxFundingDesc fn.Option [AuxFundingDesc ]
343+
340344 // fundingOutpoint is the outpoint of the completed funding
341345 // transaction as assembled by the workflow initiator.
342346 fundingOutpoint * wire.OutPoint
@@ -1489,19 +1493,14 @@ func defaultCommitOpts() createCommitOpts {
14891493 return createCommitOpts {}
14901494}
14911495
1492- // WithLocalAuxLeaves is a functional option that can be used to set the local
1493- // aux leaves for a new commitment transaction.
1494- func WithLocalAuxLeaves (leaves fn.Option [CommitAuxLeaves ]) CreateCommitOpt {
1495- return func (o * createCommitOpts ) {
1496- o .localAuxLeaves = leaves
1497- }
1498- }
1496+ // WithAuxLeaves is a functional option that can be used to set the aux leaves
1497+ // for a new commitment transaction.
1498+ func WithAuxLeaves (localLeaves ,
1499+ remoteLeaves fn.Option [CommitAuxLeaves ]) CreateCommitOpt {
14991500
1500- // WithRemoteAuxLeaves is a functional option that can be used to set the remote
1501- // aux leaves for a new commitment transaction.
1502- func WithRemoteAuxLeaves (leaves fn.Option [CommitAuxLeaves ]) CreateCommitOpt {
15031501 return func (o * createCommitOpts ) {
1504- o .remoteAuxLeaves = leaves
1502+ o .localAuxLeaves = localLeaves
1503+ o .remoteAuxLeaves = remoteLeaves
15051504 }
15061505}
15071506
@@ -1828,6 +1827,24 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
18281827 return
18291828 }
18301829
1830+ chanState := pendingReservation .partialState
1831+
1832+ // If we have an aux funding desc, then we can use it to populate some
1833+ // of the optional, but opaque TLV blobs we'll carry for the channel.
1834+ chanState .CustomBlob = fn .MapOption (func (desc AuxFundingDesc ) tlv.Blob {
1835+ return desc .CustomFundingBlob
1836+ })(req .auxFundingDesc )
1837+ chanState .LocalCommitment .CustomBlob = fn .MapOption (
1838+ func (desc AuxFundingDesc ) tlv.Blob {
1839+ return desc .CustomLocalCommitBlob
1840+ },
1841+ )(req .auxFundingDesc )
1842+ chanState .RemoteCommitment .CustomBlob = fn .MapOption (
1843+ func (desc AuxFundingDesc ) tlv.Blob {
1844+ return desc .CustomRemoteCommitBlob
1845+ },
1846+ )(req .auxFundingDesc )
1847+
18311848 ourContribution := pendingReservation .ourContribution
18321849 theirContribution := pendingReservation .theirContribution
18331850 chanPoint := pendingReservation .partialState .FundingOutpoint
@@ -1886,7 +1903,6 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
18861903 // Store their current commitment point. We'll need this after the
18871904 // first state transition in order to verify the authenticity of the
18881905 // revocation.
1889- chanState := pendingReservation .partialState
18901906 chanState .RemoteCurrentRevocation = theirContribution .FirstCommitmentPoint
18911907
18921908 // Create the txin to our commitment transaction; required to construct
@@ -1903,15 +1919,21 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
19031919 leaseExpiry = pendingReservation .partialState .ThawHeight
19041920 }
19051921
1922+ localAuxLeaves := fn .MapOption (func (desc AuxFundingDesc ) CommitAuxLeaves {
1923+ return desc .LocalInitAuxLeaves
1924+ })(req .auxFundingDesc )
1925+ remoteAuxLeaves := fn .MapOption (func (desc AuxFundingDesc ) CommitAuxLeaves {
1926+ return desc .RemoteInitAuxLeaves
1927+ })(req .auxFundingDesc )
1928+
19061929 ourCommitTx , theirCommitTx , err := CreateCommitmentTxns (
19071930 localBalance , remoteBalance , ourContribution .ChannelConfig ,
19081931 theirContribution .ChannelConfig ,
19091932 ourContribution .FirstCommitmentPoint ,
19101933 theirContribution .FirstCommitmentPoint , fundingTxIn ,
19111934 pendingReservation .partialState .ChanType ,
19121935 pendingReservation .partialState .IsInitiator , leaseExpiry ,
1913- WithLocalAuxLeaves (pendingReservation .localInitAuxLeaves ),
1914- WithRemoteAuxLeaves (pendingReservation .remoteInitAuxLeaves ),
1936+ WithAuxLeaves (localAuxLeaves , remoteAuxLeaves ),
19151937 )
19161938 if err != nil {
19171939 req .err <- err
@@ -2327,11 +2349,24 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
23272349 pendingReservation .Lock ()
23282350 defer pendingReservation .Unlock ()
23292351
2330- // TODO(roasbeef): get funding desc
2331- // * set all blobs
2332- // * get the local+remote commitAux leaves for below commitment txns
2333-
23342352 chanState := pendingReservation .partialState
2353+
2354+ // If we have an aux funding desc, then we can use it to populate some
2355+ // of the optional, but opaque TLV blobs we'll carry for the channel.
2356+ chanState .CustomBlob = fn .MapOption (func (desc AuxFundingDesc ) tlv.Blob {
2357+ return desc .CustomFundingBlob
2358+ })(req .auxFundingDesc )
2359+ chanState .LocalCommitment .CustomBlob = fn .MapOption (
2360+ func (desc AuxFundingDesc ) tlv.Blob {
2361+ return desc .CustomLocalCommitBlob
2362+ },
2363+ )(req .auxFundingDesc )
2364+ chanState .RemoteCommitment .CustomBlob = fn .MapOption (
2365+ func (desc AuxFundingDesc ) tlv.Blob {
2366+ return desc .CustomRemoteCommitBlob
2367+ },
2368+ )(req .auxFundingDesc )
2369+
23352370 chanType := pendingReservation .partialState .ChanType
23362371 chanState .FundingOutpoint = * req .fundingOutpoint
23372372 fundingTxIn := wire .NewTxIn (req .fundingOutpoint , nil , nil )
@@ -2345,6 +2380,14 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
23452380 if pendingReservation .partialState .ChanType .HasLeaseExpiration () {
23462381 leaseExpiry = pendingReservation .partialState .ThawHeight
23472382 }
2383+
2384+ localAuxLeaves := fn .MapOption (func (desc AuxFundingDesc ) CommitAuxLeaves {
2385+ return desc .LocalInitAuxLeaves
2386+ })(req .auxFundingDesc )
2387+ remoteAuxLeaves := fn .MapOption (func (desc AuxFundingDesc ) CommitAuxLeaves {
2388+ return desc .RemoteInitAuxLeaves
2389+ })(req .auxFundingDesc )
2390+
23482391 ourCommitTx , theirCommitTx , err := CreateCommitmentTxns (
23492392 localBalance , remoteBalance ,
23502393 pendingReservation .ourContribution .ChannelConfig ,
@@ -2353,8 +2396,7 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
23532396 pendingReservation .theirContribution .FirstCommitmentPoint ,
23542397 * fundingTxIn , chanType ,
23552398 pendingReservation .partialState .IsInitiator , leaseExpiry ,
2356- WithLocalAuxLeaves (pendingReservation .localInitAuxLeaves ),
2357- WithRemoteAuxLeaves (pendingReservation .remoteInitAuxLeaves ),
2399+ WithAuxLeaves (localAuxLeaves , remoteAuxLeaves ),
23582400 )
23592401 if err != nil {
23602402 req .err <- err
0 commit comments