Skip to content

Commit c00f831

Browse files
committed
cmd/loop: handle external loop in flag
1 parent 489ab56 commit c00f831

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

cmd/loop/loopin.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,29 @@ func loopIn(ctx *cli.Context) error {
5656
}
5757
defer cleanup()
5858

59+
external := ctx.Bool("external")
5960
quote, err := client.GetLoopInQuote(
6061
context.Background(),
6162
&looprpc.QuoteRequest{
62-
Amt: int64(amt),
63+
Amt: int64(amt),
64+
ExternalHtlc: external,
6365
},
6466
)
6567
if err != nil {
6668
return err
6769
}
6870

6971
limits := getInLimits(amt, quote)
70-
71-
if err := displayLimits(loop.TypeIn, amt, limits); err != nil {
72+
err = displayLimits(loop.TypeIn, amt, limits, external)
73+
if err != nil {
7274
return err
7375
}
7476

7577
resp, err := client.LoopIn(context.Background(), &looprpc.LoopInRequest{
7678
Amt: int64(amt),
7779
MaxMinerFee: int64(limits.maxMinerFee),
7880
MaxSwapFee: int64(limits.maxSwapFee),
79-
ExternalHtlc: ctx.Bool("external"),
81+
ExternalHtlc: external,
8082
})
8183
if err != nil {
8284
return err

cmd/loop/loopout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func loopOut(ctx *cli.Context) error {
9494

9595
limits := getLimits(amt, quote)
9696

97-
if err := displayLimits(loop.TypeOut, amt, limits); err != nil {
97+
if err := displayLimits(loop.TypeOut, amt, limits, false); err != nil {
9898
return err
9999
}
100100

cmd/loop/main.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,23 @@ func getLimits(amt btcutil.Amount, quote *looprpc.QuoteResponse) *limits {
116116
}
117117
}
118118

119-
func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits) error {
119+
func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits,
120+
externalHtlc bool) error {
121+
120122
totalSuccessMax := l.maxMinerFee + l.maxSwapFee
121123
if l.maxSwapRoutingFee != nil {
122124
totalSuccessMax += *l.maxSwapRoutingFee
123125
}
124126
if l.maxPrepayRoutingFee != nil {
125127
totalSuccessMax += *l.maxPrepayRoutingFee
126128
}
129+
130+
if swapType == loop.TypeIn && externalHtlc {
131+
fmt.Printf("On-chain fee for external loop in is not " +
132+
"included.\nSufficient fees will need to be paid " +
133+
"when constructing the transaction in the external " +
134+
"wallet.\n\n")
135+
}
127136

128137
fmt.Printf("Max swap fees for %d Loop %v: %d\n",
129138
btcutil.Amount(amt), swapType, totalSuccessMax,
@@ -139,7 +148,10 @@ func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits) error {
139148
return nil
140149
case "x":
141150
fmt.Println()
142-
fmt.Printf("Max on-chain fee: %d\n", l.maxMinerFee)
151+
if swapType != loop.TypeIn || !externalHtlc {
152+
fmt.Printf("Max on-chain fee: %d\n",
153+
l.maxMinerFee)
154+
}
143155

144156
if l.maxSwapRoutingFee != nil {
145157
fmt.Printf("Max off-chain swap routing fee: %d\n",

0 commit comments

Comments
 (0)