cmd/loop: handle external loop in flag

pull/86/head
Oliver Gugger 5 years ago
parent 489ab5620e
commit c00f831675
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -56,10 +56,12 @@ func loopIn(ctx *cli.Context) error {
}
defer cleanup()
external := ctx.Bool("external")
quote, err := client.GetLoopInQuote(
context.Background(),
&looprpc.QuoteRequest{
Amt: int64(amt),
Amt: int64(amt),
ExternalHtlc: external,
},
)
if err != nil {
@ -67,8 +69,8 @@ func loopIn(ctx *cli.Context) error {
}
limits := getInLimits(amt, quote)
if err := displayLimits(loop.TypeIn, amt, limits); err != nil {
err = displayLimits(loop.TypeIn, amt, limits, external)
if err != nil {
return err
}
@ -76,7 +78,7 @@ func loopIn(ctx *cli.Context) error {
Amt: int64(amt),
MaxMinerFee: int64(limits.maxMinerFee),
MaxSwapFee: int64(limits.maxSwapFee),
ExternalHtlc: ctx.Bool("external"),
ExternalHtlc: external,
})
if err != nil {
return err

@ -94,7 +94,7 @@ func loopOut(ctx *cli.Context) error {
limits := getLimits(amt, quote)
if err := displayLimits(loop.TypeOut, amt, limits); err != nil {
if err := displayLimits(loop.TypeOut, amt, limits, false); err != nil {
return err
}

@ -116,7 +116,9 @@ func getLimits(amt btcutil.Amount, quote *looprpc.QuoteResponse) *limits {
}
}
func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits) error {
func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits,
externalHtlc bool) error {
totalSuccessMax := l.maxMinerFee + l.maxSwapFee
if l.maxSwapRoutingFee != nil {
totalSuccessMax += *l.maxSwapRoutingFee
@ -124,6 +126,13 @@ func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits) error {
if l.maxPrepayRoutingFee != nil {
totalSuccessMax += *l.maxPrepayRoutingFee
}
if swapType == loop.TypeIn && externalHtlc {
fmt.Printf("On-chain fee for external loop in is not " +
"included.\nSufficient fees will need to be paid " +
"when constructing the transaction in the external " +
"wallet.\n\n")
}
fmt.Printf("Max swap fees for %d Loop %v: %d\n",
btcutil.Amount(amt), swapType, totalSuccessMax,
@ -139,7 +148,10 @@ func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits) error {
return nil
case "x":
fmt.Println()
fmt.Printf("Max on-chain fee: %d\n", l.maxMinerFee)
if swapType != loop.TypeIn || !externalHtlc {
fmt.Printf("Max on-chain fee: %d\n",
l.maxMinerFee)
}
if l.maxSwapRoutingFee != nil {
fmt.Printf("Max off-chain swap routing fee: %d\n",

Loading…
Cancel
Save