@@ -22,6 +22,7 @@ var staticAddressCommands = cli.Command{
22
22
newStaticAddressCommand ,
23
23
listUnspentCommand ,
24
24
withdrawalCommand ,
25
+ summaryCommand ,
25
26
},
26
27
}
27
28
@@ -183,6 +184,83 @@ func withdraw(ctx *cli.Context) error {
183
184
return nil
184
185
}
185
186
187
+ var summaryCommand = cli.Command {
188
+ Name : "summary" ,
189
+ ShortName : "s" ,
190
+ Usage : "Display a summary of static address related data." ,
191
+ Description : `
192
+ Displays various static address related data. Utxos, Deposits,
193
+ Withdrawls, loop-ins...
194
+ ` ,
195
+ Flags : []cli.Flag {
196
+ cli.StringFlag {
197
+ Name : "filter" ,
198
+ Usage : "specify a filter to only display deposits in " +
199
+ "the specified state. The state can be one " +
200
+ "of [deposited|withdrawing|withdrawn|" +
201
+ "publish_expired_deposit|" +
202
+ "wait_for_expiry_sweep|expired|failed]." ,
203
+ },
204
+ },
205
+ Action : summary ,
206
+ }
207
+
208
+ func summary (ctx * cli.Context ) error {
209
+ ctxb := context .Background ()
210
+ if ctx .NArg () > 0 {
211
+ return cli .ShowCommandHelp (ctx , "summary" )
212
+ }
213
+
214
+ client , cleanup , err := getClient (ctx )
215
+ if err != nil {
216
+ return err
217
+ }
218
+ defer cleanup ()
219
+
220
+ var filterState looprpc.DepositState
221
+ switch ctx .String ("filter" ) {
222
+ case "" :
223
+ // If no filter is specified, we'll default to showing all.
224
+
225
+ case "deposited" :
226
+ filterState = looprpc .DepositState_DEPOSITED
227
+
228
+ case "withdrawing" :
229
+ filterState = looprpc .DepositState_WITHDRAWING
230
+
231
+ case "withdrawn" :
232
+ filterState = looprpc .DepositState_WITHDRAWN
233
+
234
+ case "publish_expired_deposit" :
235
+ filterState = looprpc .DepositState_PUBLISH_EXPIRED
236
+
237
+ case "wait_for_expiry_sweep" :
238
+ filterState = looprpc .DepositState_WAIT_FOR_EXPIRY_SWEEP
239
+
240
+ case "expired" :
241
+ filterState = looprpc .DepositState_EXPIRED
242
+
243
+ case "failed" :
244
+ filterState = looprpc .DepositState_FAILED_STATE
245
+
246
+ default :
247
+ filterState = looprpc .DepositState_UNKNOWN_STATE
248
+ }
249
+
250
+ resp , err := client .GetStaticAddressSummary (
251
+ ctxb , & looprpc.StaticAddressSummaryRequest {
252
+ StateFilter : filterState ,
253
+ },
254
+ )
255
+ if err != nil {
256
+ return err
257
+ }
258
+
259
+ printRespJSON (resp )
260
+
261
+ return nil
262
+ }
263
+
186
264
func utxosToOutpoints (utxos []string ) ([]* looprpc.OutPoint , error ) {
187
265
var outpoints []* looprpc.OutPoint
188
266
if len (utxos ) == 0 {
0 commit comments