Skip to content

Commit 0065101

Browse files
committed
tbd
1 parent c7d2160 commit 0065101

File tree

10 files changed

+1064
-260
lines changed

10 files changed

+1064
-260
lines changed

cmd/loop/staticaddr.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var staticAddressCommands = cli.Command{
2222
newStaticAddressCommand,
2323
listUnspentCommand,
2424
withdrawalCommand,
25+
summaryCommand,
2526
},
2627
}
2728

@@ -183,6 +184,83 @@ func withdraw(ctx *cli.Context) error {
183184
return nil
184185
}
185186

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+
186264
func utxosToOutpoints(utxos []string) ([]*looprpc.OutPoint, error) {
187265
var outpoints []*looprpc.OutPoint
188266
if len(utxos) == 0 {

loopd/perms/perms.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ var RequiredPermissions = map[string][]bakery.Op{
9090
Entity: "loop",
9191
Action: "in",
9292
}},
93+
"/looprpc.SwapClient/GetStaticAddressSummary": {{
94+
Entity: "swap",
95+
Action: "read",
96+
}, {
97+
Entity: "loop",
98+
Action: "in",
99+
}},
93100
"/looprpc.SwapClient/GetLsatTokens": {{
94101
Entity: "auth",
95102
Action: "read",

0 commit comments

Comments
 (0)