multi: pass BuildBreachRetribution callback to tower client

In this commit, a new BuildBreachRetribution callback is added to the
tower client's Config struct. The main LND server provides the client
with an implementation of the callback.
This commit is contained in:
Elle Mouton committed 2023-04-24 13:15:40 +02:00
1 parent fe2304efad
commit 85ec38f447
3 files changed
+67 -6

No files matched your search

+24
View File
@@ -517,6 +517,15 @@ func newHarness(t *testing.T, cfg harnessCfg) *testHarness {
SessionCloseRange: 1,
}
h.clientCfg.BuildBreachRetribution = func(id lnwire.ChannelID,
commitHeight uint64) (*lnwallet.BreachRetribution,
channeldb.ChannelType, error) {
_, retribution := h.channelFromID(id).getState(commitHeight)
return retribution, channeldb.SingleFunderBit, nil
}
if !cfg.noServerStart {
h.startServer()
t.Cleanup(h.stopServer)
@@ -627,6 +636,21 @@ func (h *testHarness) channel(id uint64) *mockChannel {
return c
}
// channelFromID retrieves the channel corresponding to id.
//
// NOTE: The method fails if a channel for id does not exist.
func (h *testHarness) channelFromID(chanID lnwire.ChannelID) *mockChannel {
h.t.Helper()
h.mu.Lock()
defer h.mu.Unlock()
c, ok := h.channels[chanID]
require.Truef(h.t, ok, "unable to fetch channel %s", chanID)
return c
}
// closeChannel marks a channel as closed.
//
// NOTE: The method fails if a channel for id does not exist.