@@ -426,15 +426,36 @@ func (c *chainWatcher) handleUnknownLocalState(
426426 & c .cfg .chanState .LocalChanCfg , & c .cfg .chanState .RemoteChanCfg ,
427427 )
428428
429+ auxResult , err := fn .MapOptionZ (
430+ c .cfg .auxLeafStore ,
431+ //nolint:lll
432+ func (s lnwallet.AuxLeafStore ) fn.Result [lnwallet.CommitDiffAuxResult ] {
433+ return s .FetchLeavesFromCommit (
434+ lnwallet .NewAuxChanState (c .cfg .chanState ),
435+ c .cfg .chanState .LocalCommitment , * commitKeyRing ,
436+ )
437+ },
438+ ).Unpack ()
439+ if err != nil {
440+ return false , fmt .Errorf ("unable to fetch aux leaves: %w" , err )
441+ }
442+
429443 // With the keys derived, we'll construct the remote script that'll be
430444 // present if they have a non-dust balance on the commitment.
431445 var leaseExpiry uint32
432446 if c .cfg .chanState .ChanType .HasLeaseExpiration () {
433447 leaseExpiry = c .cfg .chanState .ThawHeight
434448 }
449+
450+ remoteAuxLeaf := fn .ChainOption (
451+ func (l lnwallet.CommitAuxLeaves ) input.AuxTapLeaf {
452+ return l .RemoteAuxLeaf
453+ },
454+ )(auxResult .AuxLeaves )
435455 remoteScript , _ , err := lnwallet .CommitScriptToRemote (
436456 c .cfg .chanState .ChanType , c .cfg .chanState .IsInitiator ,
437- commitKeyRing .ToRemoteKey , leaseExpiry , input .NoneTapLeaf (),
457+ commitKeyRing .ToRemoteKey , leaseExpiry ,
458+ remoteAuxLeaf ,
438459 )
439460 if err != nil {
440461 return false , err
@@ -443,11 +464,16 @@ func (c *chainWatcher) handleUnknownLocalState(
443464 // Next, we'll derive our script that includes the revocation base for
444465 // the remote party allowing them to claim this output before the CSV
445466 // delay if we breach.
467+ localAuxLeaf := fn .ChainOption (
468+ func (l lnwallet.CommitAuxLeaves ) input.AuxTapLeaf {
469+ return l .LocalAuxLeaf
470+ },
471+ )(auxResult .AuxLeaves )
446472 localScript , err := lnwallet .CommitScriptToSelf (
447473 c .cfg .chanState .ChanType , c .cfg .chanState .IsInitiator ,
448474 commitKeyRing .ToLocalKey , commitKeyRing .RevocationKey ,
449475 uint32 (c .cfg .chanState .LocalChanCfg .CsvDelay ), leaseExpiry ,
450- input . NoneTapLeaf () ,
476+ localAuxLeaf ,
451477 )
452478 if err != nil {
453479 return false , err
0 commit comments