mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loop: list unspent static address outputs
This commit is contained in:
parent
ded2526db7
commit
edea6720cb
1 changed files with 48 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ var staticAddressCommands = cli.Command{
|
|||
Category: "StaticAddress",
|
||||
Subcommands: []cli.Command{
|
||||
newStaticAddressCommand,
|
||||
listUnspentCommand,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +58,53 @@ func newStaticAddress(ctx *cli.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var listUnspentCommand = cli.Command{
|
||||
Name: "listunspent",
|
||||
ShortName: "l",
|
||||
Usage: "List unspent static address outputs.",
|
||||
Description: `
|
||||
List all unspent static address outputs.
|
||||
`,
|
||||
Flags: []cli.Flag{
|
||||
cli.IntFlag{
|
||||
Name: "min_confs",
|
||||
Usage: "The minimum amount of confirmations an " +
|
||||
"output should have to be listed.",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "max_confs",
|
||||
Usage: "The maximum number of confirmations an " +
|
||||
"output could have to be listed.",
|
||||
},
|
||||
},
|
||||
Action: listUnspent,
|
||||
}
|
||||
|
||||
func listUnspent(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
if ctx.NArg() > 0 {
|
||||
return cli.ShowCommandHelp(ctx, "listunspent")
|
||||
}
|
||||
|
||||
client, cleanup, err := getAddressClient(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cleanup()
|
||||
|
||||
resp, err := client.ListUnspent(ctxb, &looprpc.ListUnspentRequest{
|
||||
MinConfs: int32(ctx.Int("min_confs")),
|
||||
MaxConfs: int32(ctx.Int("max_confs")),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printRespJSON(resp)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getAddressClient(ctx *cli.Context) (looprpc.StaticAddressClientClient,
|
||||
func(), error) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue