From 3b630667a5ece2c1fae258e1c111f53bb4a36037 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 20 Apr 2020 18:14:43 +0200 Subject: [PATCH] cmd/loop: improve displayed limits --- cmd/loop/loopin.go | 5 ++++- cmd/loop/loopout.go | 5 ++++- cmd/loop/main.go | 35 ++++++++++++++++++++++------------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/cmd/loop/loopin.go b/cmd/loop/loopin.go index 3037f9b..dee777f 100644 --- a/cmd/loop/loopin.go +++ b/cmd/loop/loopin.go @@ -119,7 +119,10 @@ func loopIn(ctx *cli.Context) error { } limits := getInLimits(amt, quote) - err = displayLimits(swap.TypeIn, amt, limits, external, "") + err = displayLimits( + swap.TypeIn, amt, btcutil.Amount(quote.MinerFee), limits, + external, "", + ) if err != nil { return err } diff --git a/cmd/loop/loopout.go b/cmd/loop/loopout.go index a740e3b..328a5b7 100644 --- a/cmd/loop/loopout.go +++ b/cmd/loop/loopout.go @@ -135,7 +135,10 @@ func loopOut(ctx *cli.Context) error { ctx.Int64("max_swap_routing_fee"), ) } - err = displayLimits(swap.TypeOut, amt, limits, false, warning) + err = displayLimits( + swap.TypeOut, amt, btcutil.Amount(quote.MinerFee), limits, + false, warning, + ) if err != nil { return err } diff --git a/cmd/loop/main.go b/cmd/loop/main.go index 0a7f82b..9d11e47 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -141,7 +141,7 @@ func getLimits(amt btcutil.Amount, quote *looprpc.QuoteResponse) *limits { } } -func displayLimits(swapType swap.Type, amt btcutil.Amount, l *limits, +func displayLimits(swapType swap.Type, amt, minerFees btcutil.Amount, l *limits, externalHtlc bool, warning string) error { totalSuccessMax := l.maxMinerFee + l.maxSwapFee @@ -159,7 +159,7 @@ func displayLimits(swapType swap.Type, amt btcutil.Amount, l *limits, "wallet.\n\n") } - fmt.Printf("Max swap fees for %d Loop %v: %d\n", amt, swapType, + fmt.Printf("Max swap fees for %d sat Loop %v: %d sat\n", amt, swapType, totalSuccessMax) if warning != "" { @@ -176,26 +176,35 @@ func displayLimits(swapType swap.Type, amt btcutil.Amount, l *limits, return nil case "x": fmt.Println() - if swapType != swap.TypeIn || !externalHtlc { - fmt.Printf("Max on-chain fee: %d\n", - l.maxMinerFee) + f := "%-36s %d sat\n" + + switch swapType { + case swap.TypeOut: + fmt.Printf(f, "Estimated on-chain sweep fee:", + minerFees) + fmt.Printf(f, "Max on-chain sweep fee:", l.maxMinerFee) + + case swap.TypeIn: + if !externalHtlc { + fmt.Printf(f, "Estimated on-chain HTLC fee:", + minerFees) + } } if l.maxSwapRoutingFee != nil { - fmt.Printf("Max off-chain swap routing fee: %d\n", + fmt.Printf(f, "Max off-chain swap routing fee:", *l.maxSwapRoutingFee) } - if l.maxPrepayRoutingFee != nil { - fmt.Printf("Max off-chain prepay routing fee: %d\n", - *l.maxPrepayRoutingFee) - } - fmt.Printf("Max swap fee: %d\n", l.maxSwapFee) - if l.maxPrepayAmt != nil { - fmt.Printf("Max no show penalty: %d\n", + fmt.Printf(f, "Max no show penalty (prepay):", *l.maxPrepayAmt) } + if l.maxPrepayRoutingFee != nil { + fmt.Printf(f, "Max off-chain prepay routing fee:", + *l.maxPrepayRoutingFee) + } + fmt.Printf(f, "Max swap fee:", l.maxSwapFee) fmt.Printf("CONTINUE SWAP? (y/n): ") fmt.Scanln(&answer)