lncli: cancel RPC context on OS interrupts

This commit is contained in:
whythat authored and Elle Mouton committed 2021-03-12 10:07:49 +02:00
1 parent fa4155c126
commit 54c93b1b86
19 files changed
+211 -181

No files matched your search

+8 -5
View File
@@ -2,7 +2,6 @@ package main
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"io/ioutil"
@@ -75,6 +74,7 @@ var bakeMacaroonCommand = cli.Command{
}
func bakeMacaroon(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
@@ -151,7 +151,7 @@ func bakeMacaroon(ctx *cli.Context) error {
Permissions: parsedPermissions,
RootKeyId: rootKeyID,
}
resp, err := client.BakeMacaroon(context.Background(), req)
resp, err := client.BakeMacaroon(ctxc, req)
if err != nil {
return err
}
@@ -217,11 +217,12 @@ var listMacaroonIDsCommand = cli.Command{
}
func listMacaroonIDs(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
req := &lnrpc.ListMacaroonIDsRequest{}
resp, err := client.ListMacaroonIDs(context.Background(), req)
resp, err := client.ListMacaroonIDs(ctxc, req)
if err != nil {
return err
}
@@ -250,6 +251,7 @@ var deleteMacaroonIDCommand = cli.Command{
}
func deleteMacaroonID(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
@@ -277,7 +279,7 @@ func deleteMacaroonID(ctx *cli.Context) error {
req := &lnrpc.DeleteMacaroonIDRequest{
RootKeyId: rootKeyID,
}
resp, err := client.DeleteMacaroonID(context.Background(), req)
resp, err := client.DeleteMacaroonID(ctxc, req)
if err != nil {
return err
}
@@ -295,11 +297,12 @@ var listPermissionsCommand = cli.Command{
}
func listPermissions(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
request := &lnrpc.ListPermissionsRequest{}
response, err := client.ListPermissions(context.Background(), request)
response, err := client.ListPermissions(ctxc, request)
if err != nil {
return err
}