@@ -3,6 +3,7 @@ package main
33import (
44 "context"
55 "fmt"
6+ "time"
67
78 "github.com/lightninglabs/loop"
89 "github.com/lightninglabs/loop/looprpc"
@@ -44,6 +45,16 @@ var loopOutCommand = cli.Command{
4445 "should be swept within" ,
4546 Value : uint64 (loop .DefaultSweepConfTarget ),
4647 },
48+ cli.BoolFlag {
49+ Name : "fast" ,
50+ Usage : "Indicate you want to swap immediately, " +
51+ "paying potentially a higher fee. If not " +
52+ "set the swap server might choose to wait up " +
53+ "to 30 minutes before publishing the swap " +
54+ "HTLC on-chain, to save on chain fees. Not " +
55+ "setting this flag might result in a lower " +
56+ "swap fee." ,
57+ },
4758 },
4859 Action : loopOut ,
4960}
@@ -92,9 +103,19 @@ func loopOut(ctx *cli.Context) error {
92103 return err
93104 }
94105
95- limits := getLimits (amt , quote )
106+ // Show a warning if a slow swap was requested.
107+ fast := ctx .Bool ("fast" )
108+ warning := ""
109+ if fast {
110+ warning = "Fast swap requested."
111+ } else {
112+ warning = fmt .Sprintf ("Regular swap speed requested, it " +
113+ "might take up to %v for the swap to be executed." ,
114+ defaultSwapWaitTime )
115+ }
96116
97- err = displayLimits (swap .TypeOut , amt , limits , false )
117+ limits := getLimits (amt , quote )
118+ err = displayLimits (swap .TypeOut , amt , limits , false , warning )
98119 if err != nil {
99120 return err
100121 }
@@ -104,16 +125,24 @@ func loopOut(ctx *cli.Context) error {
104125 unchargeChannel = ctx .Uint64 ("channel" )
105126 }
106127
128+ // Set our maximum swap wait time. If a fast swap is requested we set
129+ // it to now, otherwise to 30 minutes in the future.
130+ swapDeadline := time .Now ()
131+ if ! fast {
132+ swapDeadline = time .Now ().Add (defaultSwapWaitTime )
133+ }
134+
107135 resp , err := client .LoopOut (context .Background (), & looprpc.LoopOutRequest {
108- Amt : int64 (amt ),
109- Dest : destAddr ,
110- MaxMinerFee : int64 (limits .maxMinerFee ),
111- MaxPrepayAmt : int64 (* limits .maxPrepayAmt ),
112- MaxSwapFee : int64 (limits .maxSwapFee ),
113- MaxPrepayRoutingFee : int64 (* limits .maxPrepayRoutingFee ),
114- MaxSwapRoutingFee : int64 (* limits .maxSwapRoutingFee ),
115- LoopOutChannel : unchargeChannel ,
116- SweepConfTarget : sweepConfTarget ,
136+ Amt : int64 (amt ),
137+ Dest : destAddr ,
138+ MaxMinerFee : int64 (limits .maxMinerFee ),
139+ MaxPrepayAmt : int64 (* limits .maxPrepayAmt ),
140+ MaxSwapFee : int64 (limits .maxSwapFee ),
141+ MaxPrepayRoutingFee : int64 (* limits .maxPrepayRoutingFee ),
142+ MaxSwapRoutingFee : int64 (* limits .maxSwapRoutingFee ),
143+ LoopOutChannel : unchargeChannel ,
144+ SweepConfTarget : sweepConfTarget ,
145+ SwapPublicationDeadline : uint64 (swapDeadline .Unix ()),
117146 })
118147 if err != nil {
119148 return err
0 commit comments