@@ -11,6 +11,7 @@ import (
1111 "github.com/btcsuite/btcd/chaincfg/chainhash"
1212 "github.com/lightninglabs/loop/labels"
1313 "github.com/lightninglabs/loop/looprpc"
14+ "github.com/lightninglabs/loop/staticaddr/deposit"
1415 "github.com/lightninglabs/loop/staticaddr/loopin"
1516 "github.com/lightninglabs/loop/swapserverrpc"
1617 "github.com/lightningnetwork/lnd/routing/route"
@@ -24,6 +25,8 @@ var staticAddressCommands = cli.Command{
2425 Subcommands : []cli.Command {
2526 newStaticAddressCommand ,
2627 listUnspentCommand ,
28+ listDepositsCommand ,
29+ listStaticAddressSwapsCommand ,
2730 withdrawalCommand ,
2831 summaryCommand ,
2932 },
@@ -217,6 +220,36 @@ func withdraw(ctx *cli.Context) error {
217220 return nil
218221}
219222
223+ var listDepositsCommand = cli.Command {
224+ Name : "listdeposits" ,
225+ Usage : "Display a summary of static address related information." ,
226+ Description : `
227+ ` ,
228+ Flags : []cli.Flag {
229+ cli.StringFlag {
230+ Name : "filter" ,
231+ Usage : "specify a filter to only display deposits in " +
232+ "the specified state. Leaving out the filter " +
233+ "returns all deposits.\n The state can be one " +
234+ "of the following: \n " +
235+ "deposited\n withdrawing\n withdrawn\n " +
236+ "looping_in\n looped_in\n " +
237+ "publish_expired_deposit\n " +
238+ "sweep_htlc_timeout\n htlc_timeout_swept\n " +
239+ "wait_for_expiry_sweep\n expired\n failed\n ." ,
240+ },
241+ },
242+ Action : listDeposits ,
243+ }
244+
245+ var listStaticAddressSwapsCommand = cli.Command {
246+ Name : "listswaps" ,
247+ Usage : "Display a summary of static address related information." ,
248+ Description : `
249+ ` ,
250+ Action : listStaticAddressSwaps ,
251+ }
252+
220253var summaryCommand = cli.Command {
221254 Name : "summary" ,
222255 ShortName : "s" ,
@@ -242,10 +275,10 @@ var summaryCommand = cli.Command{
242275 Action : summary ,
243276}
244277
245- func summary (ctx * cli.Context ) error {
278+ func listDeposits (ctx * cli.Context ) error {
246279 ctxb := context .Background ()
247280 if ctx .NArg () > 0 {
248- return cli .ShowCommandHelp (ctx , "summary " )
281+ return cli .ShowCommandHelp (ctx , "listdeposits " )
249282 }
250283
251284 client , cleanup , err := getClient (ctx )
@@ -293,8 +326,8 @@ func summary(ctx *cli.Context) error {
293326 filterState = looprpc .DepositState_UNKNOWN_STATE
294327 }
295328
296- resp , err := client .GetStaticAddressSummary (
297- ctxb , & looprpc.StaticAddressSummaryRequest {
329+ resp , err := client .ListStaticAddressDeposits (
330+ ctxb , & looprpc.ListStaticAddressDepositsRequest {
298331 StateFilter : filterState ,
299332 },
300333 )
@@ -307,6 +340,54 @@ func summary(ctx *cli.Context) error {
307340 return nil
308341}
309342
343+ func listStaticAddressSwaps (ctx * cli.Context ) error {
344+ ctxb := context .Background ()
345+ if ctx .NArg () > 0 {
346+ return cli .ShowCommandHelp (ctx , "listswaps" )
347+ }
348+
349+ client , cleanup , err := getClient (ctx )
350+ if err != nil {
351+ return err
352+ }
353+ defer cleanup ()
354+
355+ resp , err := client .ListStaticAddressSwaps (
356+ ctxb , & looprpc.ListStaticAddressSwapsRequest {},
357+ )
358+ if err != nil {
359+ return err
360+ }
361+
362+ printRespJSON (resp )
363+
364+ return nil
365+ }
366+
367+ func summary (ctx * cli.Context ) error {
368+ ctxb := context .Background ()
369+ if ctx .NArg () > 0 {
370+ return cli .ShowCommandHelp (ctx , "summary" )
371+ }
372+
373+ client , cleanup , err := getClient (ctx )
374+ if err != nil {
375+ return err
376+ }
377+ defer cleanup ()
378+
379+ resp , err := client .GetStaticAddressSummary (
380+ ctxb , & looprpc.StaticAddressSummaryRequest {},
381+ )
382+ if err != nil {
383+ return err
384+ }
385+
386+ printRespJSON (resp )
387+
388+ return nil
389+ }
390+
310391func utxosToOutpoints (utxos []string ) ([]* looprpc.OutPoint , error ) {
311392 outpoints := make ([]* looprpc.OutPoint , 0 , len (utxos ))
312393 if len (utxos ) == 0 {
@@ -391,23 +472,31 @@ func staticAddressLoopIn(ctx *cli.Context) error {
391472 }
392473
393474 // Get the amount we need to quote for.
394- summaryResp , err := client .GetStaticAddressSummary (
395- ctxb , & looprpc.StaticAddressSummaryRequest {
475+ depositList , err := client .ListStaticAddressDeposits (
476+ ctxb , & looprpc.ListStaticAddressDepositsRequest {
396477 StateFilter : looprpc .DepositState_DEPOSITED ,
397478 },
398479 )
399480 if err != nil {
400481 return err
401482 }
402483
484+ if len (depositList .FilteredDeposits ) == 0 {
485+ errString := fmt .Sprintf ("no confirmed deposits available, " +
486+ "deposits need at least %v confirmations" ,
487+ deposit .DefaultConfTarget )
488+
489+ return errors .New (errString )
490+ }
491+
403492 var depositOutpoints []string
404493 switch {
405494 case isAllSelected == isUtxoSelected :
406495 return errors .New ("must select either all or some utxos" )
407496
408497 case isAllSelected :
409498 depositOutpoints = depositsToOutpoints (
410- summaryResp .FilteredDeposits ,
499+ depositList .FilteredDeposits ,
411500 )
412501
413502 case isUtxoSelected :
@@ -437,7 +526,7 @@ func staticAddressLoopIn(ctx *cli.Context) error {
437526 // populate the quote request with the sum of selected deposits and
438527 // prompt the user for acceptance.
439528 quoteReq .Amt , err = sumDeposits (
440- depositOutpoints , summaryResp .FilteredDeposits ,
529+ depositOutpoints , depositList .FilteredDeposits ,
441530 )
442531 if err != nil {
443532 return err
0 commit comments