sweepbatcher: factor out loopdb-less version

Changed argument of function NewBatcher from LoopOutFetcher to SweepFetcher
(returning new public type SweepInfo).
This change is backwards-incompatible on the package layer, but nobody seems
to use the package outside of Loop.

To use NewBatcher inside Loop, turn loopdb into SweepFetcher using
function NewSweepFetcherFromSwapStore.
This commit is contained in:
Boris Nagaev 2024-05-14 11:36:47 -03:00
parent 295198a902
commit 0c2ba74dba
No known key found for this signature in database
5 changed files with 309 additions and 88 deletions

View file

@ -299,10 +299,15 @@ func testCustomSweepConfTarget(t *testing.T) {
batcherStore := sweepbatcher.NewStoreMock()
sweepStore, err := sweepbatcher.NewSweepFetcherFromSwapStore(
cfg.store, lnd.ChainParams,
)
require.NoError(t, err)
batcher := sweepbatcher.NewBatcher(
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
mockMuSig2SignSweep, mockVerifySchnorrSigSuccess,
lnd.ChainParams, batcherStore, cfg.store,
lnd.ChainParams, batcherStore, sweepStore,
)
tctx, cancel := context.WithCancel(context.Background())
@ -532,10 +537,15 @@ func testPreimagePush(t *testing.T) {
batcherStore := sweepbatcher.NewStoreMock()
sweepStore, err := sweepbatcher.NewSweepFetcherFromSwapStore(
cfg.store, lnd.ChainParams,
)
require.NoError(t, err)
batcher := sweepbatcher.NewBatcher(
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
mockMuSig2SignSweep, mockVerifySchnorrSigSuccess,
lnd.ChainParams, batcherStore, cfg.store,
lnd.ChainParams, batcherStore, sweepStore,
)
tctx, cancel := context.WithCancel(context.Background())
@ -953,10 +963,15 @@ func TestLoopOutMuSig2Sweep(t *testing.T) {
batcherStore := sweepbatcher.NewStoreMock()
sweepStore, err := sweepbatcher.NewSweepFetcherFromSwapStore(
cfg.store, lnd.ChainParams,
)
require.NoError(t, err)
batcher := sweepbatcher.NewBatcher(
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
mockMuSig2SignSweep, mockVerifySchnorrSigSuccess,
lnd.ChainParams, batcherStore, cfg.store,
lnd.ChainParams, batcherStore, sweepStore,
)
tctx, cancel := context.WithCancel(context.Background())