mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-20 02:56:47 +01:00
lncli: cancel RPC context on OS interrupts
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/lightninglabs/protobuf-hex-display/proto"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/lightningnetwork/lnd/signal"
|
||||
"github.com/urfave/cli"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -39,6 +40,15 @@ const (
|
||||
defaultUtxoMinConf = 1
|
||||
)
|
||||
|
||||
func getContext() context.Context {
|
||||
ctxc, cancel := context.WithCancel(context.Background())
|
||||
go func() {
|
||||
<-signal.ShutdownChannel()
|
||||
cancel()
|
||||
}()
|
||||
return ctxc
|
||||
}
|
||||
|
||||
func printJSON(resp interface{}) {
|
||||
b, err := json.Marshal(resp)
|
||||
if err != nil {
|
||||
@@ -119,6 +129,7 @@ var newAddressCommand = cli.Command{
|
||||
}
|
||||
|
||||
func newAddress(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -137,8 +148,7 @@ func newAddress(ctx *cli.Context) error {
|
||||
"are: p2wkh and np2wkh", stringAddrType)
|
||||
}
|
||||
|
||||
ctxb := context.Background()
|
||||
addr, err := client.NewAddress(ctxb, &lnrpc.NewAddressRequest{
|
||||
addr, err := client.NewAddress(ctxc, &lnrpc.NewAddressRequest{
|
||||
Type: addrType,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -172,6 +182,7 @@ var estimateFeeCommand = cli.Command{
|
||||
}
|
||||
|
||||
func estimateFees(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
var amountToAddr map[string]int64
|
||||
|
||||
jsonMap := ctx.Args().First()
|
||||
@@ -179,11 +190,10 @@ func estimateFees(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ctxb := context.Background()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
resp, err := client.EstimateFee(ctxb, &lnrpc.EstimateFeeRequest{
|
||||
resp, err := client.EstimateFee(ctxc, &lnrpc.EstimateFeeRequest{
|
||||
AddrToAmount: amountToAddr,
|
||||
TargetConf: int32(ctx.Int64("conf_target")),
|
||||
})
|
||||
@@ -260,6 +270,7 @@ func sendCoins(ctx *cli.Context) error {
|
||||
amt int64
|
||||
err error
|
||||
)
|
||||
ctxc := getContext()
|
||||
args := ctx.Args()
|
||||
|
||||
if ctx.NArg() == 0 && ctx.NumFlags() == 0 {
|
||||
@@ -299,7 +310,6 @@ func sendCoins(ctx *cli.Context) error {
|
||||
"sweep all coins out of the wallet")
|
||||
}
|
||||
|
||||
ctxb := context.Background()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -314,7 +324,7 @@ func sendCoins(ctx *cli.Context) error {
|
||||
MinConfs: minConfs,
|
||||
SpendUnconfirmed: minConfs == 0,
|
||||
}
|
||||
txid, err := client.SendCoins(ctxb, req)
|
||||
txid, err := client.SendCoins(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -367,6 +377,7 @@ func listUnspent(ctx *cli.Context) error {
|
||||
maxConfirms int64
|
||||
err error
|
||||
)
|
||||
ctxc := getContext()
|
||||
args := ctx.Args()
|
||||
|
||||
if ctx.IsSet("max_confs") && !ctx.IsSet("min_confs") {
|
||||
@@ -413,7 +424,6 @@ func listUnspent(ctx *cli.Context) error {
|
||||
maxConfirms = math.MaxInt32
|
||||
}
|
||||
|
||||
ctxb := context.Background()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -421,7 +431,7 @@ func listUnspent(ctx *cli.Context) error {
|
||||
MinConfs: int32(minConfirms),
|
||||
MaxConfs: int32(maxConfirms),
|
||||
}
|
||||
resp, err := client.ListUnspent(ctxb, req)
|
||||
resp, err := client.ListUnspent(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -481,6 +491,7 @@ var sendManyCommand = cli.Command{
|
||||
}
|
||||
|
||||
func sendMany(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
var amountToAddr map[string]int64
|
||||
|
||||
jsonMap := ctx.Args().First()
|
||||
@@ -493,12 +504,11 @@ func sendMany(ctx *cli.Context) error {
|
||||
"set, but not both")
|
||||
}
|
||||
|
||||
ctxb := context.Background()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
minConfs := int32(ctx.Uint64("min_confs"))
|
||||
txid, err := client.SendMany(ctxb, &lnrpc.SendManyRequest{
|
||||
txid, err := client.SendMany(ctxc, &lnrpc.SendManyRequest{
|
||||
AddrToAmount: amountToAddr,
|
||||
TargetConf: int32(ctx.Int64("conf_target")),
|
||||
SatPerByte: ctx.Int64("sat_per_byte"),
|
||||
@@ -546,7 +556,7 @@ var connectCommand = cli.Command{
|
||||
}
|
||||
|
||||
func connectPeer(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -567,7 +577,7 @@ func connectPeer(ctx *cli.Context) error {
|
||||
Timeout: uint64(ctx.Duration("timeout").Seconds()),
|
||||
}
|
||||
|
||||
lnid, err := client.ConnectPeer(ctxb, req)
|
||||
lnid, err := client.ConnectPeer(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -592,7 +602,7 @@ var disconnectCommand = cli.Command{
|
||||
}
|
||||
|
||||
func disconnectPeer(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -610,7 +620,7 @@ func disconnectPeer(ctx *cli.Context) error {
|
||||
PubKey: pubKey,
|
||||
}
|
||||
|
||||
lnid, err := client.DisconnectPeer(ctxb, req)
|
||||
lnid, err := client.DisconnectPeer(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -689,6 +699,7 @@ var closeChannelCommand = cli.Command{
|
||||
}
|
||||
|
||||
func closeChannel(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -731,7 +742,7 @@ func closeChannel(ctx *cli.Context) error {
|
||||
})
|
||||
}()
|
||||
|
||||
err = executeChannelClose(client, req, txidChan, ctx.Bool("block"))
|
||||
err = executeChannelClose(ctxc, client, req, txidChan, ctx.Bool("block"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -748,10 +759,10 @@ func closeChannel(ctx *cli.Context) error {
|
||||
// transaction ID is sent through `txidChan` as soon as it is broadcasted to the
|
||||
// network. The block boolean is used to determine if we should block until the
|
||||
// closing transaction receives all of its required confirmations.
|
||||
func executeChannelClose(client lnrpc.LightningClient, req *lnrpc.CloseChannelRequest,
|
||||
txidChan chan<- string, block bool) error {
|
||||
func executeChannelClose(ctxc context.Context, client lnrpc.LightningClient,
|
||||
req *lnrpc.CloseChannelRequest, txidChan chan<- string, block bool) error {
|
||||
|
||||
stream, err := client.CloseChannel(context.Background(), req)
|
||||
stream, err := client.CloseChannel(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -834,11 +845,12 @@ var closeAllChannelsCommand = cli.Command{
|
||||
}
|
||||
|
||||
func closeAllChannels(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
listReq := &lnrpc.ListChannelsRequest{}
|
||||
openChannels, err := client.ListChannels(context.Background(), listReq)
|
||||
openChannels, err := client.ListChannels(ctxc, listReq)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to fetch open channels: %v", err)
|
||||
}
|
||||
@@ -969,7 +981,7 @@ func closeAllChannels(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
txidChan := make(chan string, 1)
|
||||
err = executeChannelClose(client, req, txidChan, false)
|
||||
err = executeChannelClose(ctxc, client, req, txidChan, false)
|
||||
if err != nil {
|
||||
res.FailErr = fmt.Sprintf("unable to close "+
|
||||
"channel: %v", err)
|
||||
@@ -1044,8 +1056,7 @@ var abandonChannelCommand = cli.Command{
|
||||
}
|
||||
|
||||
func abandonChannel(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1064,7 +1075,7 @@ func abandonChannel(ctx *cli.Context) error {
|
||||
ChannelPoint: channelPoint,
|
||||
}
|
||||
|
||||
resp, err := client.AbandonChannel(ctxb, req)
|
||||
resp, err := client.AbandonChannel(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1124,7 +1135,7 @@ var listPeersCommand = cli.Command{
|
||||
}
|
||||
|
||||
func listPeers(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1133,7 +1144,7 @@ func listPeers(ctx *cli.Context) error {
|
||||
req := &lnrpc.ListPeersRequest{
|
||||
LatestError: !ctx.IsSet("list_errors"),
|
||||
}
|
||||
resp, err := client.ListPeers(ctxb, req)
|
||||
resp, err := client.ListPeers(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1150,12 +1161,12 @@ var walletBalanceCommand = cli.Command{
|
||||
}
|
||||
|
||||
func walletBalance(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.WalletBalanceRequest{}
|
||||
resp, err := client.WalletBalance(ctxb, req)
|
||||
resp, err := client.WalletBalance(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1173,12 +1184,12 @@ var channelBalanceCommand = cli.Command{
|
||||
}
|
||||
|
||||
func channelBalance(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.ChannelBalanceRequest{}
|
||||
resp, err := client.ChannelBalance(ctxb, req)
|
||||
resp, err := client.ChannelBalance(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1194,12 +1205,12 @@ var getInfoCommand = cli.Command{
|
||||
}
|
||||
|
||||
func getInfo(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.GetInfoRequest{}
|
||||
resp, err := client.GetInfo(ctxb, req)
|
||||
resp, err := client.GetInfo(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1215,12 +1226,12 @@ var getRecoveryInfoCommand = cli.Command{
|
||||
}
|
||||
|
||||
func getRecoveryInfo(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.GetRecoveryInfoRequest{}
|
||||
resp, err := client.GetRecoveryInfo(ctxb, req)
|
||||
resp, err := client.GetRecoveryInfo(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1237,12 +1248,12 @@ var pendingChannelsCommand = cli.Command{
|
||||
}
|
||||
|
||||
func pendingChannels(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.PendingChannelsRequest{}
|
||||
resp, err := client.PendingChannels(ctxb, req)
|
||||
resp, err := client.PendingChannels(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1284,7 +1295,7 @@ var listChannelsCommand = cli.Command{
|
||||
}
|
||||
|
||||
func listChannels(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1310,7 +1321,7 @@ func listChannels(ctx *cli.Context) error {
|
||||
Peer: peerKey,
|
||||
}
|
||||
|
||||
resp, err := client.ListChannels(ctxb, req)
|
||||
resp, err := client.ListChannels(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1359,7 +1370,7 @@ var closedChannelsCommand = cli.Command{
|
||||
}
|
||||
|
||||
func closedChannels(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1372,7 +1383,7 @@ func closedChannels(ctx *cli.Context) error {
|
||||
Abandoned: ctx.Bool("abandoned"),
|
||||
}
|
||||
|
||||
resp, err := client.ClosedChannels(ctxb, req)
|
||||
resp, err := client.ClosedChannels(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1400,6 +1411,7 @@ var describeGraphCommand = cli.Command{
|
||||
}
|
||||
|
||||
func describeGraph(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1407,7 +1419,7 @@ func describeGraph(ctx *cli.Context) error {
|
||||
IncludeUnannounced: ctx.Bool("include_unannounced"),
|
||||
}
|
||||
|
||||
graph, err := client.DescribeGraph(context.Background(), req)
|
||||
graph, err := client.DescribeGraph(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1425,6 +1437,7 @@ var getNodeMetricsCommand = cli.Command{
|
||||
}
|
||||
|
||||
func getNodeMetrics(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1432,7 +1445,7 @@ func getNodeMetrics(ctx *cli.Context) error {
|
||||
Types: []lnrpc.NodeMetricType{lnrpc.NodeMetricType_BETWEENNESS_CENTRALITY},
|
||||
}
|
||||
|
||||
nodeMetrics, err := client.GetNodeMetrics(context.Background(), req)
|
||||
nodeMetrics, err := client.GetNodeMetrics(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1487,6 +1500,7 @@ var listPaymentsCommand = cli.Command{
|
||||
}
|
||||
|
||||
func listPayments(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1497,7 +1511,7 @@ func listPayments(ctx *cli.Context) error {
|
||||
Reversed: !ctx.Bool("paginate_forwards"),
|
||||
}
|
||||
|
||||
payments, err := client.ListPayments(context.Background(), req)
|
||||
payments, err := client.ListPayments(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1523,7 +1537,7 @@ var getChanInfoCommand = cli.Command{
|
||||
}
|
||||
|
||||
func getChanInfo(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1548,7 +1562,7 @@ func getChanInfo(ctx *cli.Context) error {
|
||||
ChanId: uint64(chanID),
|
||||
}
|
||||
|
||||
chanInfo, err := client.GetChanInfo(ctxb, req)
|
||||
chanInfo, err := client.GetChanInfo(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1579,7 +1593,7 @@ var getNodeInfoCommand = cli.Command{
|
||||
}
|
||||
|
||||
func getNodeInfo(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1600,7 +1614,7 @@ func getNodeInfo(ctx *cli.Context) error {
|
||||
IncludeChannels: ctx.Bool("include_channels"),
|
||||
}
|
||||
|
||||
nodeInfo, err := client.GetNodeInfo(ctxb, req)
|
||||
nodeInfo, err := client.GetNodeInfo(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1655,7 +1669,7 @@ var queryRoutesCommand = cli.Command{
|
||||
}
|
||||
|
||||
func queryRoutes(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1704,7 +1718,7 @@ func queryRoutes(ctx *cli.Context) error {
|
||||
OutgoingChanId: ctx.Uint64("outgoing_chanid"),
|
||||
}
|
||||
|
||||
route, err := client.QueryRoutes(ctxb, req)
|
||||
route, err := client.QueryRoutes(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1756,13 +1770,13 @@ var getNetworkInfoCommand = cli.Command{
|
||||
}
|
||||
|
||||
func getNetworkInfo(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.NetworkInfoRequest{}
|
||||
|
||||
netInfo, err := client.GetNetworkInfo(ctxb, req)
|
||||
netInfo, err := client.GetNetworkInfo(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1792,7 +1806,7 @@ var debugLevelCommand = cli.Command{
|
||||
}
|
||||
|
||||
func debugLevel(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
req := &lnrpc.DebugLevelRequest{
|
||||
@@ -1800,7 +1814,7 @@ func debugLevel(ctx *cli.Context) error {
|
||||
LevelSpec: ctx.String("level"),
|
||||
}
|
||||
|
||||
resp, err := client.DebugLevel(ctxb, req)
|
||||
resp, err := client.DebugLevel(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1844,7 +1858,7 @@ var listChainTxnsCommand = cli.Command{
|
||||
}
|
||||
|
||||
func listChainTxns(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1857,7 +1871,7 @@ func listChainTxns(ctx *cli.Context) error {
|
||||
req.EndHeight = int32(ctx.Int64("end_height"))
|
||||
}
|
||||
|
||||
resp, err := client.GetTransactions(ctxb, req)
|
||||
resp, err := client.GetTransactions(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1876,11 +1890,11 @@ var stopCommand = cli.Command{
|
||||
}
|
||||
|
||||
func stopDaemon(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
_, err := client.StopDaemon(ctxb, &lnrpc.StopRequest{})
|
||||
_, err := client.StopDaemon(ctxc, &lnrpc.StopRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1908,7 +1922,7 @@ var signMessageCommand = cli.Command{
|
||||
}
|
||||
|
||||
func signMessage(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1923,7 +1937,7 @@ func signMessage(ctx *cli.Context) error {
|
||||
return fmt.Errorf("msg argument missing")
|
||||
}
|
||||
|
||||
resp, err := client.SignMessage(ctxb, &lnrpc.SignMessageRequest{Msg: msg})
|
||||
resp, err := client.SignMessage(ctxc, &lnrpc.SignMessageRequest{Msg: msg})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1957,7 +1971,7 @@ var verifyMessageCommand = cli.Command{
|
||||
}
|
||||
|
||||
func verifyMessage(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -1988,7 +2002,7 @@ func verifyMessage(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
req := &lnrpc.VerifyMessageRequest{Msg: msg, Signature: sig}
|
||||
resp, err := client.VerifyMessage(ctxb, req)
|
||||
resp, err := client.VerifyMessage(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2008,12 +2022,12 @@ var feeReportCommand = cli.Command{
|
||||
}
|
||||
|
||||
func feeReport(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.FeeReportRequest{}
|
||||
resp, err := client.FeeReport(ctxb, req)
|
||||
resp, err := client.FeeReport(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2101,7 +2115,7 @@ func parseChanPoint(s string) (*lnrpc.ChannelPoint, error) {
|
||||
}
|
||||
|
||||
func updateChannelPolicy(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -2196,7 +2210,7 @@ func updateChannelPolicy(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := client.UpdateChannelPolicy(ctxb, req)
|
||||
resp, err := client.UpdateChannelPolicy(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2252,7 +2266,7 @@ var forwardingHistoryCommand = cli.Command{
|
||||
}
|
||||
|
||||
func forwardingHistory(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -2321,7 +2335,7 @@ func forwardingHistory(ctx *cli.Context) error {
|
||||
IndexOffset: indexOffset,
|
||||
NumMaxEvents: maxEvents,
|
||||
}
|
||||
resp, err := client.ForwardingHistory(ctxb, req)
|
||||
resp, err := client.ForwardingHistory(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2384,7 +2398,7 @@ var exportChanBackupCommand = cli.Command{
|
||||
}
|
||||
|
||||
func exportChanBackup(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -2418,7 +2432,7 @@ func exportChanBackup(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
chanBackup, err := client.ExportChannelBackup(
|
||||
ctxb, &lnrpc.ExportChannelBackupRequest{
|
||||
ctxc, &lnrpc.ExportChannelBackupRequest{
|
||||
ChanPoint: chanPointRPC,
|
||||
},
|
||||
)
|
||||
@@ -2453,7 +2467,7 @@ func exportChanBackup(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
chanBackup, err := client.ExportAllChannelBackups(
|
||||
ctxb, &lnrpc.ChanBackupExportRequest{},
|
||||
ctxc, &lnrpc.ChanBackupExportRequest{},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -2529,7 +2543,7 @@ var verifyChanBackupCommand = cli.Command{
|
||||
}
|
||||
|
||||
func verifyChanBackup(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -2555,7 +2569,7 @@ func verifyChanBackup(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := client.VerifyChanBackup(ctxb, &verifyReq)
|
||||
resp, err := client.VerifyChanBackup(ctxc, &verifyReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2671,7 +2685,7 @@ func parseChanBackups(ctx *cli.Context) (*lnrpc.RestoreChanBackupRequest, error)
|
||||
}
|
||||
|
||||
func restoreChanBackup(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
@@ -2690,7 +2704,7 @@ func restoreChanBackup(ctx *cli.Context) error {
|
||||
|
||||
req.Backup = backups.Backup
|
||||
|
||||
_, err = client.RestoreChannelBackups(ctxb, &req)
|
||||
_, err = client.RestoreChannelBackups(ctxc, &req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to restore chan backups: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user