diff --git a/client.go b/client.go index fcf0d48..4b716f4 100644 --- a/client.go +++ b/client.go @@ -315,10 +315,7 @@ func (s *Client) Run(ctx context.Context, func (s *Client) resumeSwaps(ctx context.Context, loopOutSwaps []*loopdb.LoopOut, loopInSwaps []*loopdb.LoopIn) { - swapCfg := &swapConfig{ - lnd: s.lndServices, - store: s.Store, - } + swapCfg := newSwapConfig(s.lndServices, s.Store, s.Server) for _, pend := range loopOutSwaps { if pend.State().State.Type() != loopdb.StateTypePending { @@ -369,11 +366,7 @@ func (s *Client) LoopOut(globalCtx context.Context, // Create a new swap object for this swap. initiationHeight := s.executor.height() - swapCfg := &swapConfig{ - lnd: s.lndServices, - store: s.Store, - server: s.Server, - } + swapCfg := newSwapConfig(s.lndServices, s.Store, s.Server) swap, err := newLoopOutSwap( globalCtx, swapCfg, initiationHeight, request, ) @@ -486,13 +479,9 @@ func (s *Client) LoopIn(globalCtx context.Context, // Create a new swap object for this swap. initiationHeight := s.executor.height() - swapCfg := swapConfig{ - lnd: s.lndServices, - store: s.Store, - server: s.Server, - } + swapCfg := newSwapConfig(s.lndServices, s.Store, s.Server) swap, err := newLoopInSwap( - globalCtx, &swapCfg, initiationHeight, request, + globalCtx, swapCfg, initiationHeight, request, ) if err != nil { return nil, err diff --git a/loopin_test.go b/loopin_test.go index 08f3fd3..0af35fb 100644 --- a/loopin_test.go +++ b/loopin_test.go @@ -32,11 +32,7 @@ func TestLoopInSuccess(t *testing.T) { height := int32(600) - cfg := &swapConfig{ - lnd: &ctx.lnd.LndServices, - store: ctx.store, - server: ctx.server, - } + cfg := newSwapConfig(&ctx.lnd.LndServices, ctx.store, ctx.server) swap, err := newLoopInSwap( context.Background(), cfg, @@ -151,11 +147,7 @@ func testLoopInTimeout(t *testing.T, height := int32(600) - cfg := &swapConfig{ - lnd: &ctx.lnd.LndServices, - store: ctx.store, - server: ctx.server, - } + cfg := newSwapConfig(&ctx.lnd.LndServices, ctx.store, ctx.server) req := testLoopInRequest if externalValue != 0 { @@ -282,12 +274,7 @@ func testLoopInResume(t *testing.T, state loopdb.SwapState, expired bool) { defer test.Guard(t)() ctx := newLoopInTestContext(t) - - cfg := &swapConfig{ - lnd: &ctx.lnd.LndServices, - store: ctx.store, - server: ctx.server, - } + cfg := newSwapConfig(&ctx.lnd.LndServices, ctx.store, ctx.server) senderKey := [33]byte{4} receiverKey := [33]byte{5} diff --git a/loopout_test.go b/loopout_test.go index d5dc9de..bf97699 100644 --- a/loopout_test.go +++ b/loopout_test.go @@ -145,11 +145,7 @@ func TestLateHtlcPublish(t *testing.T) { height := int32(600) - cfg := &swapConfig{ - lnd: &lnd.LndServices, - store: store, - server: server, - } + cfg := newSwapConfig(&lnd.LndServices, store, server) swap, err := newLoopOutSwap( context.Background(), cfg, height, testRequest, @@ -231,11 +227,10 @@ func TestCustomSweepConfTarget(t *testing.T) { ctx.Lnd.SetFeeEstimate(testRequest.SweepConfTarget, 250) ctx.Lnd.SetFeeEstimate(DefaultSweepConfTarget, 10000) - cfg := &swapConfig{ - lnd: &lnd.LndServices, - store: newStoreMock(t), - server: newServerMock(), - } + cfg := newSwapConfig( + &lnd.LndServices, newStoreMock(t), newServerMock(), + ) + swap, err := newLoopOutSwap( context.Background(), cfg, ctx.Lnd.Height, testRequest, ) diff --git a/swap.go b/swap.go index a00e4b8..4ed5339 100644 --- a/swap.go +++ b/swap.go @@ -82,3 +82,13 @@ type swapConfig struct { store loopdb.SwapStore server swapServerClient } + +func newSwapConfig(lnd *lndclient.LndServices, store loopdb.SwapStore, + server swapServerClient) *swapConfig { + + return &swapConfig{ + lnd: lnd, + store: store, + server: server, + } +}