From 489ab5620ec0c3fc525e69466b9c99486fd46118 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 23 Sep 2019 10:08:34 +0200 Subject: [PATCH] loopd: receive external HTLC flag in loop in quote request --- client.go | 9 +++++++++ cmd/loopd/swapclient_server.go | 1 + interface.go | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/client.go b/client.go index 8e48bae..2422656 100644 --- a/client.go +++ b/client.go @@ -470,6 +470,15 @@ func (s *Client) LoopInQuote(ctx context.Context, request.Amount*btcutil.Amount(terms.SwapFeeRate)/ btcutil.Amount(swap.FeeRateTotalParts) + // We don't calculate the on-chain fee if the HTLC is going to be + // published externally. + if request.ExternalHtlc { + return &LoopInQuote{ + SwapFee: swapFee, + MinerFee: 0, + }, nil + } + // Get estimate for miner fee. minerFee, err := s.lndServices.Client.EstimateFeeToP2WSH( ctx, request.Amount, request.HtlcConfTarget, diff --git a/cmd/loopd/swapclient_server.go b/cmd/loopd/swapclient_server.go index 89cf775..7579cb2 100644 --- a/cmd/loopd/swapclient_server.go +++ b/cmd/loopd/swapclient_server.go @@ -306,6 +306,7 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context, quote, err := s.impl.LoopInQuote(ctx, &loop.LoopInQuoteRequest{ Amount: btcutil.Amount(req.Amt), HtlcConfTarget: defaultConfTarget, + ExternalHtlc: req.ExternalHtlc, }) if err != nil { return nil, err diff --git a/interface.go b/interface.go index 04756f5..fadc2b8 100644 --- a/interface.go +++ b/interface.go @@ -224,6 +224,10 @@ type LoopInQuoteRequest struct { // HtlcConfTarget specifies the targeted confirmation target for the // client sweep tx. HtlcConfTarget int32 + + // ExternalHtlc specifies whether the htlc is published by an external + // source. + ExternalHtlc bool } // LoopInQuote contains estimates for the fees making up the total swap cost