Skip to content

Commit 24099aa

Browse files
committed
looprpc: split terms message
1 parent 57374ef commit 24099aa

File tree

5 files changed

+252
-164
lines changed

5 files changed

+252
-164
lines changed

cmd/loop/terms.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/urfave/cli"
8-
97
"github.com/btcsuite/btcutil"
108
"github.com/lightninglabs/loop/looprpc"
9+
"github.com/urfave/cli"
1110
)
1211

1312
var termsCommand = cli.Command{
@@ -23,10 +22,9 @@ func terms(ctx *cli.Context) error {
2322
}
2423
defer cleanup()
2524

26-
printTerms := func(terms *looprpc.TermsResponse) {
25+
printAmountRange := func(min, max int64) {
2726
fmt.Printf("Amount: %d - %d\n",
28-
btcutil.Amount(terms.MinSwapAmount),
29-
btcutil.Amount(terms.MaxSwapAmount),
27+
btcutil.Amount(min), btcutil.Amount(max),
3028
)
3129
}
3230

@@ -37,7 +35,10 @@ func terms(ctx *cli.Context) error {
3735
if err != nil {
3836
fmt.Println(err)
3937
} else {
40-
printTerms(loopOutTerms)
38+
printAmountRange(
39+
loopOutTerms.MinSwapAmount,
40+
loopOutTerms.MaxSwapAmount,
41+
)
4142
}
4243

4344
fmt.Println()
@@ -50,7 +51,10 @@ func terms(ctx *cli.Context) error {
5051
if err != nil {
5152
fmt.Println(err)
5253
} else {
53-
printTerms(loopInTerms)
54+
printAmountRange(
55+
loopInTerms.MinSwapAmount,
56+
loopInTerms.MaxSwapAmount,
57+
)
5458
}
5559

5660
return nil

loopd/swapclient_server.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ func (s *swapClientServer) SwapInfo(_ context.Context,
328328

329329
// LoopOutTerms returns the terms that the server enforces for loop out swaps.
330330
func (s *swapClientServer) LoopOutTerms(ctx context.Context,
331-
req *looprpc.TermsRequest) (*looprpc.TermsResponse, error) {
331+
req *looprpc.TermsRequest) (*looprpc.OutTermsResponse, error) {
332332

333333
log.Infof("Loop out terms request received")
334334

@@ -338,7 +338,7 @@ func (s *swapClientServer) LoopOutTerms(ctx context.Context,
338338
return nil, err
339339
}
340340

341-
return &looprpc.TermsResponse{
341+
return &looprpc.OutTermsResponse{
342342
MinSwapAmount: int64(terms.MinSwapAmount),
343343
MaxSwapAmount: int64(terms.MaxSwapAmount),
344344
}, nil
@@ -376,8 +376,8 @@ func (s *swapClientServer) LoopOutQuote(ctx context.Context,
376376
}
377377

378378
// GetTerms returns the terms that the server enforces for swaps.
379-
func (s *swapClientServer) GetLoopInTerms(ctx context.Context, req *looprpc.TermsRequest) (
380-
*looprpc.TermsResponse, error) {
379+
func (s *swapClientServer) GetLoopInTerms(ctx context.Context,
380+
req *looprpc.TermsRequest) (*looprpc.InTermsResponse, error) {
381381

382382
log.Infof("Loop in terms request received")
383383

@@ -387,7 +387,7 @@ func (s *swapClientServer) GetLoopInTerms(ctx context.Context, req *looprpc.Term
387387
return nil, err
388388
}
389389

390-
return &looprpc.TermsResponse{
390+
return &looprpc.InTermsResponse{
391391
MinSwapAmount: int64(terms.MinSwapAmount),
392392
MaxSwapAmount: int64(terms.MaxSwapAmount),
393393
}, nil

0 commit comments

Comments
 (0)