mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-09 04:13:00 +01:00
cmd/lncli: print new status responses to CLI
This commit is contained in:
@@ -41,15 +41,16 @@ func sendCustom(ctx *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = client.SendCustomMessage(
|
resp, err := client.SendCustomMessage(
|
||||||
ctxc,
|
ctxc, &lnrpc.SendCustomMessageRequest{
|
||||||
&lnrpc.SendCustomMessageRequest{
|
|
||||||
Peer: peer,
|
Peer: peer,
|
||||||
Type: uint32(msgType),
|
Type: uint32(msgType),
|
||||||
Data: data,
|
Data: data,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
printRespJSON(resp)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/routing/route"
|
"github.com/lightningnetwork/lnd/routing/route"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -1781,11 +1782,7 @@ func deletePayments(ctx *cli.Context) error {
|
|||||||
failedHTLCsOnly = ctx.Bool("failed_htlcs_only")
|
failedHTLCsOnly = ctx.Bool("failed_htlcs_only")
|
||||||
includeNonFailed = ctx.Bool("include_non_failed")
|
includeNonFailed = ctx.Bool("include_non_failed")
|
||||||
err error
|
err error
|
||||||
okMsg = struct {
|
resp proto.Message
|
||||||
OK bool `json:"ok"`
|
|
||||||
}{
|
|
||||||
OK: true,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// We pack two RPCs into the same CLI so there are a few non-valid
|
// We pack two RPCs into the same CLI so there are a few non-valid
|
||||||
@@ -1812,10 +1809,12 @@ func deletePayments(ctx *cli.Context) error {
|
|||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = client.DeletePayment(ctxc, &lnrpc.DeletePaymentRequest{
|
resp, err = client.DeletePayment(
|
||||||
PaymentHash: paymentHash,
|
ctxc, &lnrpc.DeletePaymentRequest{
|
||||||
FailedHtlcsOnly: failedHTLCsOnly,
|
PaymentHash: paymentHash,
|
||||||
})
|
FailedHtlcsOnly: failedHTLCsOnly,
|
||||||
|
},
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error deleting single payment: %w",
|
return fmt.Errorf("error deleting single payment: %w",
|
||||||
err)
|
err)
|
||||||
@@ -1832,7 +1831,7 @@ func deletePayments(ctx *cli.Context) error {
|
|||||||
|
|
||||||
fmt.Printf("Removing %s payments, this might take a while...\n",
|
fmt.Printf("Removing %s payments, this might take a while...\n",
|
||||||
what)
|
what)
|
||||||
_, err = client.DeleteAllPayments(
|
resp, err = client.DeleteAllPayments(
|
||||||
ctxc, &lnrpc.DeleteAllPaymentsRequest{
|
ctxc, &lnrpc.DeleteAllPaymentsRequest{
|
||||||
AllPayments: includeNonFailed,
|
AllPayments: includeNonFailed,
|
||||||
FailedPaymentsOnly: !includeNonFailed,
|
FailedPaymentsOnly: !includeNonFailed,
|
||||||
@@ -1844,9 +1843,7 @@ func deletePayments(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Users are confused by empty JSON outputs so let's return a simple OK
|
printJSON(resp)
|
||||||
// instead of just printing the empty response RPC message.
|
|
||||||
printJSON(okMsg)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2128,11 +2128,13 @@ func stopDaemon(ctx *cli.Context) error {
|
|||||||
client, cleanUp := getClient(ctx)
|
client, cleanUp := getClient(ctx)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
_, err := client.StopDaemon(ctxc, &lnrpc.StopRequest{})
|
resp, err := client.StopDaemon(ctxc, &lnrpc.StopRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printRespJSON(resp)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2997,10 +2999,12 @@ func restoreChanBackup(ctx *cli.Context) error {
|
|||||||
|
|
||||||
req.Backup = backups.Backup
|
req.Backup = backups.Backup
|
||||||
|
|
||||||
_, err = client.RestoreChannelBackups(ctxc, &req)
|
resp, err := client.RestoreChannelBackups(ctxc, &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to restore chan backups: %w", err)
|
return fmt.Errorf("unable to restore chan backups: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printRespJSON(resp)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user