@@ -280,6 +280,8 @@ type addContributionMsg struct {
280280type continueContributionMsg struct {
281281 pendingFundingID uint64
282282
283+ auxFundingDesc fn.Option [AuxFundingDesc ]
284+
283285 // NOTE: In order to avoid deadlocks, this channel MUST be buffered.
284286 err chan error
285287}
@@ -335,6 +337,8 @@ type addCounterPartySigsMsg struct {
335337type addSingleFunderSigsMsg struct {
336338 pendingFundingID uint64
337339
340+ auxFundingDesc fn.Option [AuxFundingDesc ]
341+
338342 // fundingOutpoint is the outpoint of the completed funding
339343 // transaction as assembled by the workflow initiator.
340344 fundingOutpoint * wire.OutPoint
@@ -1475,7 +1479,8 @@ func (l *LightningWallet) handleFundingCancelRequest(req *fundingReserveCancelMs
14751479// createCommitOpts is a struct that holds the options for creating a a new
14761480// commitment transaction.
14771481type createCommitOpts struct {
1478- auxLeaves fn.Option [CommitAuxLeaves ]
1482+ localAuxLeaves fn.Option [CommitAuxLeaves ]
1483+ remoteAuxLeaves fn.Option [CommitAuxLeaves ]
14791484}
14801485
14811486// defaultCommitOpts returns a new createCommitOpts with default values.
@@ -1485,11 +1490,12 @@ func defaultCommitOpts() createCommitOpts {
14851490
14861491// WithAuxLeaves is a functional option that can be used to set the aux leaves
14871492// for a new commitment transaction.
1488- //
1489- // TODO(roasbeef): local+remote leaves
1490- func WithAuxLeaves ( leaves fn. Option [ CommitAuxLeaves ]) CreateCommitOpt {
1493+ func WithAuxLeaves ( localLeaves , remoteLeaves fn. Option [ CommitAuxLeaves ],
1494+ ) CreateCommitOpt {
1495+
14911496 return func (o * createCommitOpts ) {
1492- o .auxLeaves = leaves
1497+ o .localAuxLeaves = localLeaves
1498+ o .remoteAuxLeaves = remoteLeaves
14931499 }
14941500}
14951501
@@ -1523,7 +1529,7 @@ func CreateCommitmentTxns(localBalance, remoteBalance btcutil.Amount,
15231529 ourCommitTx , err := CreateCommitTx (
15241530 chanType , fundingTxIn , localCommitmentKeys , ourChanCfg ,
15251531 theirChanCfg , localBalance , remoteBalance , 0 , initiator ,
1526- leaseExpiry , options .auxLeaves ,
1532+ leaseExpiry , options .localAuxLeaves ,
15271533 )
15281534 if err != nil {
15291535 return nil , nil , err
@@ -1537,7 +1543,7 @@ func CreateCommitmentTxns(localBalance, remoteBalance btcutil.Amount,
15371543 theirCommitTx , err := CreateCommitTx (
15381544 chanType , fundingTxIn , remoteCommitmentKeys , theirChanCfg ,
15391545 ourChanCfg , remoteBalance , localBalance , 0 , ! initiator ,
1540- leaseExpiry , options .auxLeaves ,
1546+ leaseExpiry , options .remoteAuxLeaves ,
15411547 )
15421548 if err != nil {
15431549 return nil , nil , err
@@ -1816,6 +1822,24 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
18161822 return
18171823 }
18181824
1825+ chanState := pendingReservation .partialState
1826+
1827+ // If we have an aux funding desc, then we can use it to populate some
1828+ // of the optional, but opaque TLV blobs we'll carry for the channel.
1829+ chanState .CustomBlob = fn .MapOption (func (desc AuxFundingDesc ) tlv.Blob {
1830+ return desc .CustomFundingBlob
1831+ })(req .auxFundingDesc )
1832+ chanState .LocalCommitment .CustomBlob = fn .MapOption (
1833+ func (desc AuxFundingDesc ) tlv.Blob {
1834+ return desc .CustomLocalCommitBlob
1835+ },
1836+ )(req .auxFundingDesc )
1837+ chanState .RemoteCommitment .CustomBlob = fn .MapOption (
1838+ func (desc AuxFundingDesc ) tlv.Blob {
1839+ return desc .CustomRemoteCommitBlob
1840+ },
1841+ )(req .auxFundingDesc )
1842+
18191843 ourContribution := pendingReservation .ourContribution
18201844 theirContribution := pendingReservation .theirContribution
18211845 chanPoint := pendingReservation .partialState .FundingOutpoint
@@ -1874,7 +1898,6 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
18741898 // Store their current commitment point. We'll need this after the
18751899 // first state transition in order to verify the authenticity of the
18761900 // revocation.
1877- chanState := pendingReservation .partialState
18781901 chanState .RemoteCurrentRevocation = theirContribution .FirstCommitmentPoint
18791902
18801903 // Create the txin to our commitment transaction; required to construct
@@ -1891,14 +1914,21 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
18911914 leaseExpiry = pendingReservation .partialState .ThawHeight
18921915 }
18931916
1917+ localAuxLeaves := fn .MapOption (func (desc AuxFundingDesc ) CommitAuxLeaves {
1918+ return desc .LocalInitAuxLeaves
1919+ })(req .auxFundingDesc )
1920+ remoteAuxLeaves := fn .MapOption (func (desc AuxFundingDesc ) CommitAuxLeaves {
1921+ return desc .RemoteInitAuxLeaves
1922+ })(req .auxFundingDesc )
1923+
18941924 ourCommitTx , theirCommitTx , err := CreateCommitmentTxns (
18951925 localBalance , remoteBalance , ourContribution .ChannelConfig ,
18961926 theirContribution .ChannelConfig ,
18971927 ourContribution .FirstCommitmentPoint ,
18981928 theirContribution .FirstCommitmentPoint , fundingTxIn ,
18991929 pendingReservation .partialState .ChanType ,
19001930 pendingReservation .partialState .IsInitiator , leaseExpiry ,
1901- WithAuxLeaves (pendingReservation . initAuxLeaves ),
1931+ WithAuxLeaves (localAuxLeaves , remoteAuxLeaves ),
19021932 )
19031933 if err != nil {
19041934 req .err <- err
@@ -2314,11 +2344,24 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
23142344 pendingReservation .Lock ()
23152345 defer pendingReservation .Unlock ()
23162346
2317- // TODO(roasbeef): get funding desc
2318- // * set all blobs
2319- // * get the local+remote commitAux leaves for below commitment txns
2320-
23212347 chanState := pendingReservation .partialState
2348+
2349+ // If we have an aux funding desc, then we can use it to populate some
2350+ // of the optional, but opaque TLV blobs we'll carry for the channel.
2351+ chanState .CustomBlob = fn .MapOption (func (desc AuxFundingDesc ) tlv.Blob {
2352+ return desc .CustomFundingBlob
2353+ })(req .auxFundingDesc )
2354+ chanState .LocalCommitment .CustomBlob = fn .MapOption (
2355+ func (desc AuxFundingDesc ) tlv.Blob {
2356+ return desc .CustomLocalCommitBlob
2357+ },
2358+ )(req .auxFundingDesc )
2359+ chanState .RemoteCommitment .CustomBlob = fn .MapOption (
2360+ func (desc AuxFundingDesc ) tlv.Blob {
2361+ return desc .CustomRemoteCommitBlob
2362+ },
2363+ )(req .auxFundingDesc )
2364+
23222365 chanType := pendingReservation .partialState .ChanType
23232366 chanState .FundingOutpoint = * req .fundingOutpoint
23242367 fundingTxIn := wire .NewTxIn (req .fundingOutpoint , nil , nil )
@@ -2332,6 +2375,14 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
23322375 if pendingReservation .partialState .ChanType .HasLeaseExpiration () {
23332376 leaseExpiry = pendingReservation .partialState .ThawHeight
23342377 }
2378+
2379+ localAuxLeaves := fn .MapOption (func (desc AuxFundingDesc ) CommitAuxLeaves {
2380+ return desc .LocalInitAuxLeaves
2381+ })(req .auxFundingDesc )
2382+ remoteAuxLeaves := fn .MapOption (func (desc AuxFundingDesc ) CommitAuxLeaves {
2383+ return desc .RemoteInitAuxLeaves
2384+ })(req .auxFundingDesc )
2385+
23352386 ourCommitTx , theirCommitTx , err := CreateCommitmentTxns (
23362387 localBalance , remoteBalance ,
23372388 pendingReservation .ourContribution .ChannelConfig ,
@@ -2340,7 +2391,7 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
23402391 pendingReservation .theirContribution .FirstCommitmentPoint ,
23412392 * fundingTxIn , chanType ,
23422393 pendingReservation .partialState .IsInitiator , leaseExpiry ,
2343- WithAuxLeaves (pendingReservation . initAuxLeaves ),
2394+ WithAuxLeaves (localAuxLeaves , remoteAuxLeaves ),
23442395 )
23452396 if err != nil {
23462397 req .err <- err
0 commit comments