@@ -11,6 +11,61 @@ import (
11
11
var quoteCommand = cli.Command {
12
12
Name : "quote" ,
13
13
Usage : "get a quote for the cost of a swap" ,
14
+ Subcommands : []cli.Command {quoteInCommand , quoteOutCommand },
15
+ }
16
+
17
+ var quoteInCommand = cli.Command {
18
+ Name : "in" ,
19
+ Usage : "get a quote for the cost of a loop in swap" ,
20
+ ArgsUsage : "amt" ,
21
+ Description : "Allows to determine the cost of a swap up front" ,
22
+ Flags : []cli.Flag {
23
+ cli.Uint64Flag {
24
+ Name : "conf_target" ,
25
+ Usage : "the number of blocks from the swap " +
26
+ "initiation height that the on-chain HTLC " +
27
+ "should be swept within in a Loop Out" ,
28
+ Value : 6 ,
29
+ },
30
+ },
31
+ Action : quoteIn ,
32
+ }
33
+
34
+ func quoteIn (ctx * cli.Context ) error {
35
+ // Show command help if the incorrect number arguments was provided.
36
+ if ctx .NArg () != 1 {
37
+ return cli .ShowCommandHelp (ctx , "in" )
38
+ }
39
+
40
+ args := ctx .Args ()
41
+ amt , err := parseAmt (args [0 ])
42
+ if err != nil {
43
+ return err
44
+ }
45
+
46
+ client , cleanup , err := getClient (ctx )
47
+ if err != nil {
48
+ return err
49
+ }
50
+ defer cleanup ()
51
+
52
+ ctxb := context .Background ()
53
+ quoteReq := & looprpc.QuoteRequest {
54
+ Amt : int64 (amt ),
55
+ ConfTarget : int32 (ctx .Uint64 ("conf_target" )),
56
+ }
57
+ quoteResp , err := client .GetLoopInQuote (ctxb , quoteReq )
58
+ if err != nil {
59
+ return err
60
+ }
61
+
62
+ printRespJSON (quoteResp )
63
+ return nil
64
+ }
65
+
66
+ var quoteOutCommand = cli.Command {
67
+ Name : "out" ,
68
+ Usage : "get a quote for the cost of a loop out swap" ,
14
69
ArgsUsage : "amt" ,
15
70
Description : "Allows to determine the cost of a swap up front" ,
16
71
Flags : []cli.Flag {
@@ -32,13 +87,13 @@ var quoteCommand = cli.Command{
32
87
"swap fee." ,
33
88
},
34
89
},
35
- Action : quote ,
90
+ Action : quoteOut ,
36
91
}
37
92
38
- func quote (ctx * cli.Context ) error {
93
+ func quoteOut (ctx * cli.Context ) error {
39
94
// Show command help if the incorrect number arguments was provided.
40
95
if ctx .NArg () != 1 {
41
- return cli .ShowCommandHelp (ctx , "quote " )
96
+ return cli .ShowCommandHelp (ctx , "out " )
42
97
}
43
98
44
99
args := ctx .Args ()
@@ -60,15 +115,16 @@ func quote(ctx *cli.Context) error {
60
115
}
61
116
62
117
ctxb := context .Background ()
63
- resp , err := client . LoopOutQuote ( ctxb , & looprpc.QuoteRequest {
118
+ quoteReq := & looprpc.QuoteRequest {
64
119
Amt : int64 (amt ),
65
120
ConfTarget : int32 (ctx .Uint64 ("conf_target" )),
66
121
SwapPublicationDeadline : uint64 (swapDeadline .Unix ()),
67
- })
122
+ }
123
+ quoteResp , err := client .LoopOutQuote (ctxb , quoteReq )
68
124
if err != nil {
69
125
return err
70
126
}
71
127
72
- printRespJSON (resp )
128
+ printRespJSON (quoteResp )
73
129
return nil
74
130
}
0 commit comments