@@ -426,15 +426,36 @@ func (c *chainWatcher) handleUnknownLocalState(
426
426
& c .cfg .chanState .LocalChanCfg , & c .cfg .chanState .RemoteChanCfg ,
427
427
)
428
428
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
+
429
443
// With the keys derived, we'll construct the remote script that'll be
430
444
// present if they have a non-dust balance on the commitment.
431
445
var leaseExpiry uint32
432
446
if c .cfg .chanState .ChanType .HasLeaseExpiration () {
433
447
leaseExpiry = c .cfg .chanState .ThawHeight
434
448
}
449
+
450
+ remoteAuxLeaf := fn .ChainOption (
451
+ func (l lnwallet.CommitAuxLeaves ) input.AuxTapLeaf {
452
+ return l .RemoteAuxLeaf
453
+ },
454
+ )(auxResult .AuxLeaves )
435
455
remoteScript , _ , err := lnwallet .CommitScriptToRemote (
436
456
c .cfg .chanState .ChanType , c .cfg .chanState .IsInitiator ,
437
- commitKeyRing .ToRemoteKey , leaseExpiry , input .NoneTapLeaf (),
457
+ commitKeyRing .ToRemoteKey , leaseExpiry ,
458
+ remoteAuxLeaf ,
438
459
)
439
460
if err != nil {
440
461
return false , err
@@ -443,11 +464,16 @@ func (c *chainWatcher) handleUnknownLocalState(
443
464
// Next, we'll derive our script that includes the revocation base for
444
465
// the remote party allowing them to claim this output before the CSV
445
466
// delay if we breach.
467
+ localAuxLeaf := fn .ChainOption (
468
+ func (l lnwallet.CommitAuxLeaves ) input.AuxTapLeaf {
469
+ return l .LocalAuxLeaf
470
+ },
471
+ )(auxResult .AuxLeaves )
446
472
localScript , err := lnwallet .CommitScriptToSelf (
447
473
c .cfg .chanState .ChanType , c .cfg .chanState .IsInitiator ,
448
474
commitKeyRing .ToLocalKey , commitKeyRing .RevocationKey ,
449
475
uint32 (c .cfg .chanState .LocalChanCfg .CsvDelay ), leaseExpiry ,
450
- input . NoneTapLeaf () ,
476
+ localAuxLeaf ,
451
477
)
452
478
if err != nil {
453
479
return false , err
0 commit comments