Skip to content

Commit 1bcaf1e

Browse files
committed
loop: list unspent static address outputs
1 parent 1d52f63 commit 1bcaf1e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

cmd/loop/staticaddr.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var staticAddressCommands = cli.Command{
1515
Category: "StaticAddress",
1616
Subcommands: []cli.Command{
1717
newStaticAddressCommand,
18+
listUnspentCommand,
1819
},
1920
}
2021

@@ -57,6 +58,53 @@ func newStaticAddress(ctx *cli.Context) error {
5758
return nil
5859
}
5960

61+
var listUnspentCommand = cli.Command{
62+
Name: "listunspent",
63+
ShortName: "l",
64+
Usage: "List unspent static address outputs.",
65+
Description: `
66+
List all unspent static address outputs.
67+
`,
68+
Flags: []cli.Flag{
69+
cli.IntFlag{
70+
Name: "min_confs",
71+
Usage: "The minimum amount of confirmations an " +
72+
"output should have to be listed.",
73+
},
74+
cli.IntFlag{
75+
Name: "max_confs",
76+
Usage: "The maximum number of confirmations an " +
77+
"output could have to be listed.",
78+
},
79+
},
80+
Action: listUnspent,
81+
}
82+
83+
func listUnspent(ctx *cli.Context) error {
84+
ctxb := context.Background()
85+
if ctx.NArg() > 0 {
86+
return cli.ShowCommandHelp(ctx, "listunspent")
87+
}
88+
89+
client, cleanup, err := getAddressClient(ctx)
90+
if err != nil {
91+
return err
92+
}
93+
defer cleanup()
94+
95+
resp, err := client.ListUnspent(ctxb, &looprpc.ListUnspentRequest{
96+
MinConfs: int32(ctx.Int("min_confs")),
97+
MaxConfs: int32(ctx.Int("max_confs")),
98+
})
99+
if err != nil {
100+
return err
101+
}
102+
103+
printRespJSON(resp)
104+
105+
return nil
106+
}
107+
60108
func getAddressClient(ctx *cli.Context) (looprpc.StaticAddressClientClient,
61109
func(), error) {
62110

0 commit comments

Comments
 (0)