mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-11 00:42:58 +02:00
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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user