Skip to content

Commit 3b63066

Browse files
committed
cmd/loop: improve displayed limits
1 parent 4a714e0 commit 3b63066

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

cmd/loop/loopin.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ func loopIn(ctx *cli.Context) error {
119119
}
120120

121121
limits := getInLimits(amt, quote)
122-
err = displayLimits(swap.TypeIn, amt, limits, external, "")
122+
err = displayLimits(
123+
swap.TypeIn, amt, btcutil.Amount(quote.MinerFee), limits,
124+
external, "",
125+
)
123126
if err != nil {
124127
return err
125128
}

cmd/loop/loopout.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ func loopOut(ctx *cli.Context) error {
135135
ctx.Int64("max_swap_routing_fee"),
136136
)
137137
}
138-
err = displayLimits(swap.TypeOut, amt, limits, false, warning)
138+
err = displayLimits(
139+
swap.TypeOut, amt, btcutil.Amount(quote.MinerFee), limits,
140+
false, warning,
141+
)
139142
if err != nil {
140143
return err
141144
}

cmd/loop/main.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func getLimits(amt btcutil.Amount, quote *looprpc.QuoteResponse) *limits {
141141
}
142142
}
143143

144-
func displayLimits(swapType swap.Type, amt btcutil.Amount, l *limits,
144+
func displayLimits(swapType swap.Type, amt, minerFees btcutil.Amount, l *limits,
145145
externalHtlc bool, warning string) error {
146146

147147
totalSuccessMax := l.maxMinerFee + l.maxSwapFee
@@ -159,7 +159,7 @@ func displayLimits(swapType swap.Type, amt btcutil.Amount, l *limits,
159159
"wallet.\n\n")
160160
}
161161

162-
fmt.Printf("Max swap fees for %d Loop %v: %d\n", amt, swapType,
162+
fmt.Printf("Max swap fees for %d sat Loop %v: %d sat\n", amt, swapType,
163163
totalSuccessMax)
164164

165165
if warning != "" {
@@ -176,26 +176,35 @@ func displayLimits(swapType swap.Type, amt btcutil.Amount, l *limits,
176176
return nil
177177
case "x":
178178
fmt.Println()
179-
if swapType != swap.TypeIn || !externalHtlc {
180-
fmt.Printf("Max on-chain fee: %d\n",
181-
l.maxMinerFee)
179+
f := "%-36s %d sat\n"
180+
181+
switch swapType {
182+
case swap.TypeOut:
183+
fmt.Printf(f, "Estimated on-chain sweep fee:",
184+
minerFees)
185+
fmt.Printf(f, "Max on-chain sweep fee:", l.maxMinerFee)
186+
187+
case swap.TypeIn:
188+
if !externalHtlc {
189+
fmt.Printf(f, "Estimated on-chain HTLC fee:",
190+
minerFees)
191+
}
182192
}
183193

184194
if l.maxSwapRoutingFee != nil {
185-
fmt.Printf("Max off-chain swap routing fee: %d\n",
195+
fmt.Printf(f, "Max off-chain swap routing fee:",
186196
*l.maxSwapRoutingFee)
187197
}
188198

189-
if l.maxPrepayRoutingFee != nil {
190-
fmt.Printf("Max off-chain prepay routing fee: %d\n",
191-
*l.maxPrepayRoutingFee)
192-
}
193-
fmt.Printf("Max swap fee: %d\n", l.maxSwapFee)
194-
195199
if l.maxPrepayAmt != nil {
196-
fmt.Printf("Max no show penalty: %d\n",
200+
fmt.Printf(f, "Max no show penalty (prepay):",
197201
*l.maxPrepayAmt)
198202
}
203+
if l.maxPrepayRoutingFee != nil {
204+
fmt.Printf(f, "Max off-chain prepay routing fee:",
205+
*l.maxPrepayRoutingFee)
206+
}
207+
fmt.Printf(f, "Max swap fee:", l.maxSwapFee)
199208

200209
fmt.Printf("CONTINUE SWAP? (y/n): ")
201210
fmt.Scanln(&answer)

0 commit comments

Comments
 (0)