lnwallet: add whoseCommit to FetchLeavesFromCommit

This is useful for additional context to know which commit the
AuxLeafStore is fetching the leaves for.
This commit is contained in:
Olaoluwa Osuntokun 2024-11-07 18:42:42 -08:00 committed by Oliver Gugger
parent b8035d9db7
commit 6db7d42654
No known key found for this signature in database
GPG key ID: 8E4256593F177720
5 changed files with 13 additions and 8 deletions

View file

@ -436,6 +436,7 @@ func (c *chainWatcher) handleUnknownLocalState(
return s.FetchLeavesFromCommit(
lnwallet.NewAuxChanState(c.cfg.chanState),
c.cfg.chanState.LocalCommitment, *commitKeyRing,
lntypes.Local,
)
},
).Unpack()

View file

@ -178,7 +178,8 @@ type AuxLeafStore interface {
// commitment.
FetchLeavesFromCommit(chanState AuxChanState,
commit channeldb.ChannelCommitment,
keyRing CommitmentKeyRing) fn.Result[CommitDiffAuxResult]
keyRing CommitmentKeyRing, whoseCommit lntypes.ChannelParty,
) fn.Result[CommitDiffAuxResult]
// FetchLeavesFromRevocation attempts to fetch the auxiliary leaves
// from a channel revocation that stores balance + blob information.

View file

@ -666,6 +666,7 @@ func (lc *LightningChannel) diskCommitToMemCommit(
return s.FetchLeavesFromCommit(
NewAuxChanState(lc.channelState), *diskCommit,
*commitKeys.GetForParty(whoseCommit),
whoseCommit,
)
},
).Unpack()
@ -1798,7 +1799,7 @@ func (lc *LightningChannel) restorePendingLocalUpdates(
func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] {
return s.FetchLeavesFromCommit(
NewAuxChanState(lc.channelState), pendingCommit,
*pendingRemoteKeys,
*pendingRemoteKeys, lntypes.Remote,
)
},
).Unpack()
@ -3219,7 +3220,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing,
leafStore, func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] {
return s.FetchLeavesFromCommit(
NewAuxChanState(chanState), *diskCommit,
*keyRing,
*keyRing, lntypes.Remote,
)
},
).Unpack()
@ -4764,7 +4765,7 @@ func genHtlcSigValidationJobs(chanState *channeldb.OpenChannel,
leafStore, func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] {
return s.FetchLeavesFromCommit(
NewAuxChanState(chanState), *diskCommit,
*keyRing,
*keyRing, lntypes.Local,
)
},
).Unpack()
@ -6668,7 +6669,7 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, //nolint:funlen
leafStore, func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] {
return s.FetchLeavesFromCommit(
NewAuxChanState(chanState), remoteCommit,
*keyRing,
*keyRing, lntypes.Remote,
)
},
).Unpack()
@ -7890,6 +7891,7 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel,
return s.FetchLeavesFromCommit(
NewAuxChanState(chanState),
chanState.LocalCommitment, *keyRing,
lntypes.Local,
)
},
).Unpack()

View file

@ -1307,7 +1307,7 @@ func findOutputIndexesFromRemote(revocationPreimage *chainhash.Hash,
leafStore, func(a AuxLeafStore) fn.Result[CommitDiffAuxResult] {
return a.FetchLeavesFromCommit(
NewAuxChanState(chanState), chanCommit,
*keyRing,
*keyRing, lntypes.Remote,
)
},
).Unpack()

View file

@ -19,6 +19,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/tlv"
"github.com/stretchr/testify/mock"
@ -412,8 +413,8 @@ func (*MockAuxLeafStore) FetchLeavesFromView(
// correspond to the passed aux blob, and an existing channel
// commitment.
func (*MockAuxLeafStore) FetchLeavesFromCommit(_ AuxChanState,
_ channeldb.ChannelCommitment,
_ CommitmentKeyRing) fn.Result[CommitDiffAuxResult] {
_ channeldb.ChannelCommitment, _ CommitmentKeyRing,
_ lntypes.ChannelParty) fn.Result[CommitDiffAuxResult] {
return fn.Ok(CommitDiffAuxResult{})
}