Skip to content

Commit f7676c3

Browse files
committed
loop: show correct swap type
1 parent f7f9751 commit f7676c3

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

cmd/loop/loopin.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/btcsuite/btcutil"
8+
"github.com/lightninglabs/loop"
89
"github.com/lightninglabs/loop/looprpc"
910
"github.com/urfave/cli"
1011
)
@@ -67,7 +68,7 @@ func loopIn(ctx *cli.Context) error {
6768

6869
limits := getInLimits(amt, quote)
6970

70-
if err := displayLimits(amt, limits); err != nil {
71+
if err := displayLimits(loop.TypeIn, amt, limits); err != nil {
7172
return err
7273
}
7374

cmd/loop/loopout.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/lightninglabs/loop"
78
"github.com/lightninglabs/loop/looprpc"
89
"github.com/urfave/cli"
910
)
@@ -84,7 +85,7 @@ func loopOut(ctx *cli.Context) error {
8485

8586
limits := getLimits(amt, quote)
8687

87-
if err := displayLimits(amt, limits); err != nil {
88+
if err := displayLimits(loop.TypeOut, amt, limits); err != nil {
8889
return err
8990
}
9091

cmd/loop/main.go

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

119-
func displayLimits(amt btcutil.Amount, l *limits) error {
119+
func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits) error {
120120
totalSuccessMax := l.maxMinerFee + l.maxSwapFee
121121
if l.maxSwapRoutingFee != nil {
122122
totalSuccessMax += *l.maxSwapRoutingFee
@@ -125,8 +125,8 @@ func displayLimits(amt btcutil.Amount, l *limits) error {
125125
totalSuccessMax += *l.maxPrepayRoutingFee
126126
}
127127

128-
fmt.Printf("Max swap fees for %d loop out: %d\n",
129-
btcutil.Amount(amt), totalSuccessMax,
128+
fmt.Printf("Max swap fees for %d Loop %v: %d\n",
129+
btcutil.Amount(amt), swapType, totalSuccessMax,
130130
)
131131

132132
fmt.Printf("CONTINUE SWAP? (y/n), expand fee detail (x): ")

interface.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,17 @@ const (
267267
TypeOut
268268
)
269269

270+
func (t Type) String() string {
271+
switch t {
272+
case TypeIn:
273+
return "In"
274+
case TypeOut:
275+
return "Out"
276+
default:
277+
return "Unknown"
278+
}
279+
}
280+
270281
// SwapInfo exposes common info fields for loop in and loop out swaps.
271282
type SwapInfo struct {
272283
LastUpdate time.Time

0 commit comments

Comments
 (0)