From 1f5aeff45f53d9fa26de5ca940dd9d275fde22a6 Mon Sep 17 00:00:00 2001 From: carla Date: Wed, 15 Apr 2020 09:10:21 +0200 Subject: [PATCH] multi: unify default sweep/htlc conf targets Create a HtlcConfTarget which is used as a default for quote and loop in. Update loop out quote to use the existing var rather than just 6 inline. --- cmd/loop/quote.go | 2 +- loopd/start.go | 5 +---- loopd/swapclient_server.go | 4 ++-- loopout.go | 4 ++++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/loop/quote.go b/cmd/loop/quote.go index 44e9a3a..6396da1 100644 --- a/cmd/loop/quote.go +++ b/cmd/loop/quote.go @@ -88,7 +88,7 @@ var quoteOutCommand = cli.Command{ Usage: "the number of blocks from the swap " + "initiation height that the on-chain HTLC " + "should be swept within in a Loop Out", - Value: 6, + Value: uint64(loop.DefaultSweepConfTarget), }, cli.BoolFlag{ Name: "fast", diff --git a/loopd/start.go b/loopd/start.go index 1acc1ae..7c11f14 100644 --- a/loopd/start.go +++ b/loopd/start.go @@ -14,10 +14,7 @@ import ( "github.com/lightningnetwork/lnd/build" ) -const ( - defaultConfTarget = int32(6) - defaultConfigFilename = "loopd.conf" -) +const defaultConfigFilename = "loopd.conf" // RPCConfig holds optional options that can be used to make the loop daemon // communicate on custom connections. diff --git a/loopd/swapclient_server.go b/loopd/swapclient_server.go index 6e2945f..b03fafd 100644 --- a/loopd/swapclient_server.go +++ b/loopd/swapclient_server.go @@ -363,7 +363,7 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context, quote, err := s.impl.LoopInQuote(ctx, &loop.LoopInQuoteRequest{ Amount: btcutil.Amount(req.Amt), - HtlcConfTarget: defaultConfTarget, + HtlcConfTarget: loop.DefaultHtlcConfTarget, ExternalHtlc: req.ExternalHtlc, }) if err != nil { @@ -385,7 +385,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context, Amount: btcutil.Amount(in.Amt), MaxMinerFee: btcutil.Amount(in.MaxMinerFee), MaxSwapFee: btcutil.Amount(in.MaxSwapFee), - HtlcConfTarget: defaultConfTarget, + HtlcConfTarget: loop.DefaultHtlcConfTarget, ExternalHtlc: in.ExternalHtlc, } if in.LastHop != nil { diff --git a/loopout.go b/loopout.go index 82b0f92..883ca8d 100644 --- a/loopout.go +++ b/loopout.go @@ -26,6 +26,10 @@ var ( // when sweeping on-chain HTLCs. DefaultSweepConfTarget int32 = 6 + // DefaultHtlcConfTarget is the default confirmation target we'll use + // for on-chain htlcs published by the swap client for Loop In. + DefaultHtlcConfTarget int32 = 6 + // DefaultSweepConfTargetDelta is the delta of blocks from a Loop Out // swap's expiration height at which we begin to use the default sweep // confirmation target.