Skip to content

Commit 6db7d42

Browse files
Roasbeefguggero
authored andcommitted
lnwallet: add whoseCommit to FetchLeavesFromCommit
This is useful for additional context to know which commit the AuxLeafStore is fetching the leaves for.
1 parent b8035d9 commit 6db7d42

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

contractcourt/chain_watcher.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ func (c *chainWatcher) handleUnknownLocalState(
436436
return s.FetchLeavesFromCommit(
437437
lnwallet.NewAuxChanState(c.cfg.chanState),
438438
c.cfg.chanState.LocalCommitment, *commitKeyRing,
439+
lntypes.Local,
439440
)
440441
},
441442
).Unpack()

lnwallet/aux_leaf_store.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ type AuxLeafStore interface {
178178
// commitment.
179179
FetchLeavesFromCommit(chanState AuxChanState,
180180
commit channeldb.ChannelCommitment,
181-
keyRing CommitmentKeyRing) fn.Result[CommitDiffAuxResult]
181+
keyRing CommitmentKeyRing, whoseCommit lntypes.ChannelParty,
182+
) fn.Result[CommitDiffAuxResult]
182183

183184
// FetchLeavesFromRevocation attempts to fetch the auxiliary leaves
184185
// from a channel revocation that stores balance + blob information.

lnwallet/channel.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ func (lc *LightningChannel) diskCommitToMemCommit(
666666
return s.FetchLeavesFromCommit(
667667
NewAuxChanState(lc.channelState), *diskCommit,
668668
*commitKeys.GetForParty(whoseCommit),
669+
whoseCommit,
669670
)
670671
},
671672
).Unpack()
@@ -1798,7 +1799,7 @@ func (lc *LightningChannel) restorePendingLocalUpdates(
17981799
func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] {
17991800
return s.FetchLeavesFromCommit(
18001801
NewAuxChanState(lc.channelState), pendingCommit,
1801-
*pendingRemoteKeys,
1802+
*pendingRemoteKeys, lntypes.Remote,
18021803
)
18031804
},
18041805
).Unpack()
@@ -3219,7 +3220,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing,
32193220
leafStore, func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] {
32203221
return s.FetchLeavesFromCommit(
32213222
NewAuxChanState(chanState), *diskCommit,
3222-
*keyRing,
3223+
*keyRing, lntypes.Remote,
32233224
)
32243225
},
32253226
).Unpack()
@@ -4764,7 +4765,7 @@ func genHtlcSigValidationJobs(chanState *channeldb.OpenChannel,
47644765
leafStore, func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] {
47654766
return s.FetchLeavesFromCommit(
47664767
NewAuxChanState(chanState), *diskCommit,
4767-
*keyRing,
4768+
*keyRing, lntypes.Local,
47684769
)
47694770
},
47704771
).Unpack()
@@ -6668,7 +6669,7 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, //nolint:funlen
66686669
leafStore, func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] {
66696670
return s.FetchLeavesFromCommit(
66706671
NewAuxChanState(chanState), remoteCommit,
6671-
*keyRing,
6672+
*keyRing, lntypes.Remote,
66726673
)
66736674
},
66746675
).Unpack()
@@ -7890,6 +7891,7 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel,
78907891
return s.FetchLeavesFromCommit(
78917892
NewAuxChanState(chanState),
78927893
chanState.LocalCommitment, *keyRing,
7894+
lntypes.Local,
78937895
)
78947896
},
78957897
).Unpack()

lnwallet/commitment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ func findOutputIndexesFromRemote(revocationPreimage *chainhash.Hash,
13071307
leafStore, func(a AuxLeafStore) fn.Result[CommitDiffAuxResult] {
13081308
return a.FetchLeavesFromCommit(
13091309
NewAuxChanState(chanState), chanCommit,
1310-
*keyRing,
1310+
*keyRing, lntypes.Remote,
13111311
)
13121312
},
13131313
).Unpack()

lnwallet/mock.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/lightningnetwork/lnd/chainntnfs"
2020
"github.com/lightningnetwork/lnd/channeldb"
2121
"github.com/lightningnetwork/lnd/fn"
22+
"github.com/lightningnetwork/lnd/lntypes"
2223
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
2324
"github.com/lightningnetwork/lnd/tlv"
2425
"github.com/stretchr/testify/mock"
@@ -412,8 +413,8 @@ func (*MockAuxLeafStore) FetchLeavesFromView(
412413
// correspond to the passed aux blob, and an existing channel
413414
// commitment.
414415
func (*MockAuxLeafStore) FetchLeavesFromCommit(_ AuxChanState,
415-
_ channeldb.ChannelCommitment,
416-
_ CommitmentKeyRing) fn.Result[CommitDiffAuxResult] {
416+
_ channeldb.ChannelCommitment, _ CommitmentKeyRing,
417+
_ lntypes.ChannelParty) fn.Result[CommitDiffAuxResult] {
417418

418419
return fn.Ok(CommitDiffAuxResult{})
419420
}

0 commit comments

Comments
 (0)