loop: show correct swap type

This commit is contained in:
Joost Jager 2019-04-02 09:31:01 +02:00
parent f7f9751a1a
commit f7676c3489
No known key found for this signature in database
GPG key ID: A61B9D4C393C59C7
4 changed files with 18 additions and 5 deletions

View file

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

View file

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

View file

@ -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
if l.maxSwapRoutingFee != nil {
totalSuccessMax += *l.maxSwapRoutingFee
@ -125,8 +125,8 @@ func displayLimits(amt btcutil.Amount, l *limits) error {
totalSuccessMax += *l.maxPrepayRoutingFee
}
fmt.Printf("Max swap fees for %d loop out: %d\n",
btcutil.Amount(amt), totalSuccessMax,
fmt.Printf("Max swap fees for %d Loop %v: %d\n",
btcutil.Amount(amt), swapType, totalSuccessMax,
)
fmt.Printf("CONTINUE SWAP? (y/n), expand fee detail (x): ")

View file

@ -267,6 +267,17 @@ const (
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.
type SwapInfo struct {
LastUpdate time.Time