loop: show correct swap type

pull/34/head
Joost Jager 5 years ago
parent f7f9751a1a
commit f7676c3489
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/lightninglabs/loop"
"github.com/lightninglabs/loop/looprpc" "github.com/lightninglabs/loop/looprpc"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -67,7 +68,7 @@ func loopIn(ctx *cli.Context) error {
limits := getInLimits(amt, quote) limits := getInLimits(amt, quote)
if err := displayLimits(amt, limits); err != nil { if err := displayLimits(loop.TypeIn, amt, limits); err != nil {
return err return err
} }

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/lightninglabs/loop"
"github.com/lightninglabs/loop/looprpc" "github.com/lightninglabs/loop/looprpc"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -84,7 +85,7 @@ func loopOut(ctx *cli.Context) error {
limits := getLimits(amt, quote) limits := getLimits(amt, quote)
if err := displayLimits(amt, limits); err != nil { if err := displayLimits(loop.TypeOut, amt, limits); err != nil {
return err return err
} }

@ -116,7 +116,7 @@ func getLimits(amt btcutil.Amount, quote *looprpc.QuoteResponse) *limits {
} }
} }
func displayLimits(amt btcutil.Amount, l *limits) error { func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits) error {
totalSuccessMax := l.maxMinerFee + l.maxSwapFee totalSuccessMax := l.maxMinerFee + l.maxSwapFee
if l.maxSwapRoutingFee != nil { if l.maxSwapRoutingFee != nil {
totalSuccessMax += *l.maxSwapRoutingFee totalSuccessMax += *l.maxSwapRoutingFee
@ -125,8 +125,8 @@ func displayLimits(amt btcutil.Amount, l *limits) error {
totalSuccessMax += *l.maxPrepayRoutingFee totalSuccessMax += *l.maxPrepayRoutingFee
} }
fmt.Printf("Max swap fees for %d loop out: %d\n", fmt.Printf("Max swap fees for %d Loop %v: %d\n",
btcutil.Amount(amt), totalSuccessMax, btcutil.Amount(amt), swapType, totalSuccessMax,
) )
fmt.Printf("CONTINUE SWAP? (y/n), expand fee detail (x): ") fmt.Printf("CONTINUE SWAP? (y/n), expand fee detail (x): ")

@ -267,6 +267,17 @@ const (
TypeOut TypeOut
) )
func (t Type) String() string {
switch t {
case TypeIn:
return "In"
case TypeOut:
return "Out"
default:
return "Unknown"
}
}
// SwapInfo exposes common info fields for loop in and loop out swaps. // SwapInfo exposes common info fields for loop in and loop out swaps.
type SwapInfo struct { type SwapInfo struct {
LastUpdate time.Time LastUpdate time.Time

Loading…
Cancel
Save