Skip to main content

DecodePayReq

DecodePayReq takes an encoded payment request string and attempts to decode it, returning a full description of the conditions encoded within the payment request.

Source: lightning.proto

gRPC

rpc DecodePayReq (PayReqString) returns (PayReq);

REST

HTTP MethodPath
GET /v1/payreq/{pay_req}

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:10009'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
const TLS_PATH = 'LND_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('lightning.proto', loaderOptions);
const lnrpc = grpc.loadPackageDefinition(packageDefinition).lnrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new lnrpc.Lightning(GRPC_HOST, creds);
let request = {
pay_req: <string>,
};
client.decodePayReq(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "destination": <string>,
// "payment_hash": <string>,
// "num_satoshis": <int64>,
// "timestamp": <int64>,
// "expiry": <int64>,
// "description": <string>,
// "description_hash": <string>,
// "fallback_addr": <string>,
// "cltv_expiry": <int64>,
// "route_hints": <RouteHint>,
// "payment_addr": <bytes>,
// "num_msat": <int64>,
// "features": <FeaturesEntry>,
// "blinded_paths": <BlindedPaymentPath>,
// }

Messages

lnrpc.PayReqString

Source: lightning.proto

FieldgRPC TypeREST TypeREST Placement
pay_req
stringstringpath

lnrpc.PayReq

Source: lightning.proto

FieldgRPC TypeREST Type
destination
stringstring
payment_hash
stringstring
num_satoshis
int64string
timestamp
int64string
expiry
int64string
description
stringstring
description_hash
stringstring
fallback_addr
stringstring
cltv_expiry
int64string
route_hints
RouteHint[]array
payment_addr
bytesstring
num_msat
int64string
features
FeaturesEntry[]object
blinded_paths
BlindedPaymentPath[]array

Nested Messages

lnrpc.BlindedHop

FieldgRPC TypeREST Type
blinded_node
bytesstring
encrypted_data
bytesstring

lnrpc.BlindedPath

FieldgRPC TypeREST Type
introduction_node
bytesstring
blinding_point
bytesstring
blinded_hops
BlindedHop[]array

lnrpc.BlindedPaymentPath

FieldgRPC TypeREST Type
blinded_path
BlindedPathobject
base_fee_msat
uint64string
proportional_fee_rate
uint32integer
total_cltv_delta
uint32integer
htlc_min_msat
uint64string
htlc_max_msat
uint64string
features
FeatureBit[]array

lnrpc.Feature

FieldgRPC TypeREST Type
name
stringstring
is_required
boolboolean
is_known
boolboolean

lnrpc.HopHint

FieldgRPC TypeREST Type
node_id
stringstring
chan_id
uint64string
fee_base_msat
uint32integer
fee_proportional_millionths
uint32integer
cltv_expiry_delta
uint32integer

lnrpc.PayReq.FeaturesEntry

FieldgRPC TypeREST Type
key
uint32unknown
value
Featureunknown

lnrpc.RouteHint

FieldgRPC TypeREST Type
hop_hints
HopHint[]array

Enums

lnrpc.FeatureBit

NameNumber
DATALOSS_PROTECT_REQ
0
DATALOSS_PROTECT_OPT
1
INITIAL_ROUING_SYNC
3
UPFRONT_SHUTDOWN_SCRIPT_REQ
4
UPFRONT_SHUTDOWN_SCRIPT_OPT
5
GOSSIP_QUERIES_REQ
6
GOSSIP_QUERIES_OPT
7
TLV_ONION_REQ
8
TLV_ONION_OPT
9
EXT_GOSSIP_QUERIES_REQ
10
EXT_GOSSIP_QUERIES_OPT
11
STATIC_REMOTE_KEY_REQ
12
STATIC_REMOTE_KEY_OPT
13
PAYMENT_ADDR_REQ
14
PAYMENT_ADDR_OPT
15
MPP_REQ
16
MPP_OPT
17
WUMBO_CHANNELS_REQ
18
WUMBO_CHANNELS_OPT
19
ANCHORS_REQ
20
ANCHORS_OPT
21
ANCHORS_ZERO_FEE_HTLC_REQ
22
ANCHORS_ZERO_FEE_HTLC_OPT
23
ROUTE_BLINDING_REQUIRED
24
ROUTE_BLINDING_OPTIONAL
25
AMP_REQ
30
AMP_OPT
31