@@ -3,6 +3,7 @@ package main
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "time"
6
7
7
8
"github.com/lightninglabs/loop"
8
9
"github.com/lightninglabs/loop/looprpc"
@@ -44,6 +45,16 @@ var loopOutCommand = cli.Command{
44
45
"should be swept within" ,
45
46
Value : uint64 (loop .DefaultSweepConfTarget ),
46
47
},
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
+ },
47
58
},
48
59
Action : loopOut ,
49
60
}
@@ -92,9 +103,19 @@ func loopOut(ctx *cli.Context) error {
92
103
return err
93
104
}
94
105
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
+ }
96
116
97
- err = displayLimits (swap .TypeOut , amt , limits , false )
117
+ limits := getLimits (amt , quote )
118
+ err = displayLimits (swap .TypeOut , amt , limits , false , warning )
98
119
if err != nil {
99
120
return err
100
121
}
@@ -104,16 +125,24 @@ func loopOut(ctx *cli.Context) error {
104
125
unchargeChannel = ctx .Uint64 ("channel" )
105
126
}
106
127
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
+
107
135
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 ()),
117
146
})
118
147
if err != nil {
119
148
return err
0 commit comments