Skip to content

Commit 486497b

Browse files
committed
staticaddr: add swap client to cmd
1 parent 1d14245 commit 486497b

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

Diff for: cmd/loop/staticaddr.go

+9-26
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ func newStaticAddress(ctx *cli.Context) error {
3939
return cli.ShowCommandHelp(ctx, "new")
4040
}
4141

42-
client, cleanup, err := getAddressClient(ctx)
42+
client, cleanup, err := getClient(ctx)
4343
if err != nil {
4444
return err
4545
}
4646
defer cleanup()
4747

48-
resp, err := client.NewAddress(
49-
ctxb, &looprpc.NewAddressRequest{},
48+
resp, err := client.NewStaticAddress(
49+
ctxb, &looprpc.NewStaticAddressRequest{},
5050
)
5151
if err != nil {
5252
return err
@@ -86,16 +86,17 @@ func listUnspent(ctx *cli.Context) error {
8686
return cli.ShowCommandHelp(ctx, "listunspent")
8787
}
8888

89-
client, cleanup, err := getAddressClient(ctx)
89+
client, cleanup, err := getClient(ctx)
9090
if err != nil {
9191
return err
9292
}
9393
defer cleanup()
9494

95-
resp, err := client.ListUnspent(ctxb, &looprpc.ListUnspentRequest{
96-
MinConfs: int32(ctx.Int("min_confs")),
97-
MaxConfs: int32(ctx.Int("max_confs")),
98-
})
95+
resp, err := client.ListUnspentDeposits(
96+
ctxb, &looprpc.ListUnspentDepositsRequest{
97+
MinConfs: int32(ctx.Int("min_confs")),
98+
MaxConfs: int32(ctx.Int("max_confs")),
99+
})
99100
if err != nil {
100101
return err
101102
}
@@ -104,21 +105,3 @@ func listUnspent(ctx *cli.Context) error {
104105

105106
return nil
106107
}
107-
108-
func getAddressClient(ctx *cli.Context) (looprpc.StaticAddressClientClient,
109-
func(), error) {
110-
111-
rpcServer := ctx.GlobalString("rpcserver")
112-
tlsCertPath, macaroonPath, err := extractPathArgs(ctx)
113-
if err != nil {
114-
return nil, nil, err
115-
}
116-
conn, err := getClientConn(rpcServer, tlsCertPath, macaroonPath)
117-
if err != nil {
118-
return nil, nil, err
119-
}
120-
cleanup := func() { conn.Close() }
121-
122-
addressClient := looprpc.NewStaticAddressClientClient(conn)
123-
return addressClient, cleanup, nil
124-
}

0 commit comments

Comments
 (0)