rpcserver+cmd/lncli: implement DecodePayReq
This commit implements the newly added RPC to decode payment requests passed over the command line or directly via gRPC. With this tool, users can now examine payment requests they see in the wild for diagnostic or debugging purposes.
This commit is contained in:
4 files changed
+56
No files matched your search
@@ -531,6 +531,8 @@ func listChannels(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO(roasbeef): defer close the client for the all
|
||||
|
||||
printRespJson(resp)
|
||||
|
||||
return nil
|
||||
@@ -955,3 +957,33 @@ func debugLevel(ctx *cli.Context) error {
|
||||
printRespJson(resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
var DecodePayReq = cli.Command{
|
||||
Name: "decodepayreq",
|
||||
Usage: "decodepayreq --pay_req=[encoded_pay_req]",
|
||||
Description: "Decode the passed payment request revealing the destination, payment hash and value of the payment request",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "pay_req",
|
||||
Usage: "the zpay32 encoded payment request",
|
||||
},
|
||||
},
|
||||
Action: decodePayReq,
|
||||
}
|
||||
|
||||
func decodePayReq(ctx *cli.Context) error {
|
||||
ctxb := context.Background()
|
||||
client := getClient(ctx)
|
||||
|
||||
req := &lnrpc.PayReqString{
|
||||
PayReq: ctx.String("pay_req"),
|
||||
}
|
||||
|
||||
resp, err := client.DecodePayReq(ctxb, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printRespJson(resp)
|
||||
return nil
|
||||
}
|
||||
@@ -71,6 +71,7 @@ func main() {
|
||||
QueryRouteCommand,
|
||||
GetNetworkInfoCommand,
|
||||
DebugLevel,
|
||||
DecodePayReq,
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
|
||||
Reference in new issue
Block a user