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 -7
View File
@@ -1,7 +1,6 @@
package main
import (
"context"
"encoding/hex"
"fmt"
"strconv"
@@ -74,7 +73,7 @@ func addInvoice(ctx *cli.Context) error {
amt int64
err error
)
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
@@ -117,7 +116,7 @@ func addInvoice(ctx *cli.Context) error {
Private: ctx.Bool("private"),
}
resp, err := client.AddInvoice(context.Background(), invoice)
resp, err := client.AddInvoice(ctxc, invoice)
if err != nil {
return err
}
@@ -143,6 +142,7 @@ var lookupInvoiceCommand = cli.Command{
}
func lookupInvoice(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
@@ -168,7 +168,7 @@ func lookupInvoice(ctx *cli.Context) error {
RHash: rHash,
}
invoice, err := client.LookupInvoice(context.Background(), req)
invoice, err := client.LookupInvoice(ctxc, req)
if err != nil {
return err
}
@@ -225,6 +225,7 @@ var listInvoicesCommand = cli.Command{
}
func listInvoices(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
@@ -235,7 +236,7 @@ func listInvoices(ctx *cli.Context) error {
Reversed: !ctx.Bool("paginate-forwards"),
}
invoices, err := client.ListInvoices(context.Background(), req)
invoices, err := client.ListInvoices(ctxc, req)
if err != nil {
return err
}
@@ -261,7 +262,7 @@ var decodePayReqCommand = cli.Command{
}
func decodePayReq(ctx *cli.Context) error {
ctxb := context.Background()
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
@@ -276,7 +277,7 @@ func decodePayReq(ctx *cli.Context) error {
return fmt.Errorf("pay_req argument missing")
}
resp, err := client.DecodePayReq(ctxb, &lnrpc.PayReqString{
resp, err := client.DecodePayReq(ctxc, &lnrpc.PayReqString{
PayReq: payreq,
})
if err != nil {