@@ -11,6 +11,61 @@ import (
1111var quoteCommand = cli.Command {
1212 Name : "quote" ,
1313 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" ,
1469 ArgsUsage : "amt" ,
1570 Description : "Allows to determine the cost of a swap up front" ,
1671 Flags : []cli.Flag {
@@ -32,13 +87,13 @@ var quoteCommand = cli.Command{
3287 "swap fee." ,
3388 },
3489 },
35- Action : quote ,
90+ Action : quoteOut ,
3691}
3792
38- func quote (ctx * cli.Context ) error {
93+ func quoteOut (ctx * cli.Context ) error {
3994 // Show command help if the incorrect number arguments was provided.
4095 if ctx .NArg () != 1 {
41- return cli .ShowCommandHelp (ctx , "quote " )
96+ return cli .ShowCommandHelp (ctx , "out " )
4297 }
4398
4499 args := ctx .Args ()
@@ -60,15 +115,16 @@ func quote(ctx *cli.Context) error {
60115 }
61116
62117 ctxb := context .Background ()
63- resp , err := client . LoopOutQuote ( ctxb , & looprpc.QuoteRequest {
118+ quoteReq := & looprpc.QuoteRequest {
64119 Amt : int64 (amt ),
65120 ConfTarget : int32 (ctx .Uint64 ("conf_target" )),
66121 SwapPublicationDeadline : uint64 (swapDeadline .Unix ()),
67- })
122+ }
123+ quoteResp , err := client .LoopOutQuote (ctxb , quoteReq )
68124 if err != nil {
69125 return err
70126 }
71127
72- printRespJSON (resp )
128+ printRespJSON (quoteResp )
73129 return nil
74130}
0 commit comments