Skip to content

Commit 3cd9253

Browse files
Roasbeefguggero
authored andcommitted
lnwallet: pass tap leaf through in NewLocalForceCloseSummary
Before this commit, the leaf wasn't yet passed in on force close. This is needed to detect the force close outputs properly.
1 parent a37c36c commit 3cd9253

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lnwallet/channel.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7696,14 +7696,29 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel,
76967696
&chanState.LocalChanCfg, &chanState.RemoteChanCfg,
76977697
)
76987698

7699+
localCommit := chanState.LocalCommitment
7700+
7701+
// If we have a custom blob, then we'll attempt to fetch the aux leaves
7702+
// for this state.
7703+
auxLeaves, err := AuxLeavesFromCommit(
7704+
chanState, localCommit, leafStore, *keyRing,
7705+
)
7706+
if err != nil {
7707+
return nil, fmt.Errorf("unable to fetch aux leaves: %w", err)
7708+
}
7709+
76997710
var leaseExpiry uint32
77007711
if chanState.ChanType.HasLeaseExpiration() {
77017712
leaseExpiry = chanState.ThawHeight
77027713
}
7714+
7715+
localAuxLeaf := fn.MapOption(func(l CommitAuxLeaves) input.AuxTapLeaf {
7716+
return l.LocalAuxLeaf
7717+
})(auxLeaves)
77037718
toLocalScript, err := CommitScriptToSelf(
77047719
chanState.ChanType, chanState.IsInitiator, keyRing.ToLocalKey,
77057720
keyRing.RevocationKey, csvTimeout, leaseExpiry,
7706-
input.NoneTapLeaf(),
7721+
fn.FlattenOption(localAuxLeaf),
77077722
)
77087723
if err != nil {
77097724
return nil, err
@@ -7817,15 +7832,6 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel,
78177832
// outgoing HTLC's that we'll need to claim as well. If this is after
78187833
// recovery there is not much we can do with HTLCs, so we'll always
78197834
// use what we have in our latest state when extracting resolutions.
7820-
localCommit := chanState.LocalCommitment
7821-
7822-
auxLeaves, err := AuxLeavesFromCommit(
7823-
chanState, localCommit, leafStore, *keyRing,
7824-
)
7825-
if err != nil {
7826-
return nil, fmt.Errorf("unable to fetch aux leaves: %w", err)
7827-
}
7828-
78297835
htlcResolutions, err := extractHtlcResolutions(
78307836
chainfee.SatPerKWeight(localCommit.FeePerKw), true, signer,
78317837
localCommit.Htlcs, keyRing, &chanState.LocalChanCfg,

0 commit comments

Comments
 (0)