LIGHTNING-PAY(7)
πΈ LIGHTNING-PAY(7) β the pay page, bestie edition π
okay so before we even start: this is LIGHTNING-PAY(7), the manual page for pay. it's giving "legacy icon who's retiring" and honestly we need to talk about it π«Ά
β¨ NAME β¨
pay β the command for sending a payment to a BOLT11/BOLT12 invoice. that's it. that's the whole vibe. π
πΈ SYNOPSIS πΈ
pay bolt11 [amount_msat] [label] [riskfactor] [maxfeepercent]
[retry_for] [maxdelay] [exemptfee] [localinvreqid] [exclude] [maxfee]
[description] [partial_msat]
like, look at all those positional params. she's long. she's iconic. she's positional-argument-core. π
π DESCRIPTION π
bestie, listen. This command was deprecated in v26.06, and removed after v27.03. it's literally on its way out. π
NOTE: As of v26.06, xpay transparently handles most pay invocations, and pay is deprecated. so likeβ¦ go hang out with xpay (that's lightning-xpay(7)) but the info's all here for you anyway, no gatekeeping π
So β what does the pay RPC command do? It attempts to find a route to the given destination, and send the funds it asks for. slay. that's the whole job.
The response will occur when the payment fails or succeeds. And here's the cute part: once a payment has succeeded, calls to pay with the same bolt11 will succeed immediately. no re-negotiating. she remembers. π
When using $ lightning-cli, you may skip optional parameters by using null. Alternatively, use the -k option to provide parameters by name. (the -k life hack, iykyk π§)
Now the params, one by one, no skips:
bolt11(string) β NOTE:invstringis an alternate name for this parameter, since v26.06, forxpaycompatibility. This is a Bolt11 or bolt12 invoice (such as one received fromlightningd-fetchinvoice(7)). For a bolt11 invoice, if it does not contain an amount,amount_msatis required, otherwise if it is specified it must benull. so like, read the invoice first, don't just yolo it πamount_msat(msat, optional) βamount_msatis in millisatoshi precision; it can be a whole number, or a whole number with suffixmsatorsat, or a three decimal point number with suffixsat, or an 1 to 11 decimal point number suffixed bybtc. formats for days. βlabel(string, optional) β It is used to attach a label to payments, and is returned inlightning-listpays(7)andlightning-listsendpays(7). it's literally a name tag for your payment πriskfactor(number, optional) β Theriskfactoris described in detail inlightning-getroute(7). The default is10.maxfeepercent(number, optional) β Percentage of the amount that is to be paid. The default is0.5.retry_for(u16, optional) β Untilretry_forseconds passes, the command will keep finding routes and retrying the payment. The default is60seconds. she's persistent. she's not giving up on you. π€maxdelay(u16, optional) β A payment may be delayed for up tomaxdelayblocks by another node; clients should be prepared for this worst case. plan accordingly bestie π¦exemptfee(msat, optional) β This option can be used for tiny payments which would be dominated by the fee leveraged by forwarding nodes. Settingexemptfeeallows themaxfeepercentcheck to be skipped on fees that are smaller thanexemptfee. The default is5000millisatoshi. tiny payment rights πlocalinvreqid(hex, optional) βlocalinvreqidis used by offers to link a payment attempt to a local invoice_request offer created bylightningd-invoicerequest(7). This ensures that we only make a single payment for an offer, and that the offer is marked used once paid. one payment, one offer, no double-dipping πexclude(array, optional) βexcludeis a JSON array of short-channel-id/direction (e.g.[ '564334x877x1/0', '564195x1292x0/1' ]) or pubkey which should be excluded from consideration for routing. The default is not to exclude any channels or nodes. the blocklist energy we deserve π- (
short_channel_id_dir) - (
pubkey)
- (
maxfee(msat, optional) βmaxfeeoverrides bothmaxfeepercentandexemptfeedefaults (and if you specifymaxfeeyou cannot specify either of those), and creates an absolute limit on what fee we will pay. This allows you to implement your own heuristics rather than the primitive ones used here. you're the heuristics now β¨description(string, optional) β It is only required for bolt11 invoices which do not contain a description themselves, but contain a description hash: in this casedescriptionis required.descriptionis then checked against the hash inside the invoice before it will be paid. hash check before bag check, fr fr π₯partial_msat(msat, optional) β Explicitly state that you are only paying some part of the invoice. Presumably someone else is paying the rest (otherwise the payment will time out at the recipient). Note that this is currently not supported for self-payment (please file an issue if you need this) (added v23.05). splitting the bill but make it lightning π«Ά
π¦ RANDOMIZATION π¦
To protect user privacy, the payment algorithm performs some randomization. yes, the algorithm has main character energy and also a privacy budget. we love to see it π
1: Route Randomization
Route randomization means the payment algorithm does not always use the lowest-fee or shortest route. This prevents some highly-connected node from learning all of the user payments by reducing their fees below the network average. like, stop being nosy, Brenda. π
2: Shadow Route
Shadow route means the payment algorithm will virtually extend the route by adding delays and fees along it, making it appear to intermediate nodes that the route is longer than it actually is. This prevents intermediate nodes from reliably guessing their distance from the payee. fake distance, real privacy, no cap β¨
Route randomization will never exceed maxfeepercent of the payment. Route randomization and shadow routing will not take routes that would exceed maxdelay. so your limits are respected, always πΈ
π RETURN VALUE π
On success, an object is returned, containing:
payment_preimage(secret) β The proof of payment: SHA256 of thispayment_hash.payment_hash(hash) β The hash of thepayment_preimagewhich will prove payment.created_at(number) β The UNIX timestamp showing when this payment was initiated.parts(u32) β How many attempts this took.amount_msat(msat) β Amount the recipient received.amount_sent_msat(msat) β Total amount we sent (including fees).status(string) (one of"complete","pending","failed") β Status of payment.destination(pubkey, optional) β The final destination of the payment.
The following warnings may also be returned:
warning_partial_completionβ Not all parts of a multi-part payment have completed.
You can monitor the progress and retries of a payment using the lightning-paystatus(7) command. go check on her, she's doing her best π
π ERRORS π
The following error codes may occur:
-1β Catchall nonspecific error. the "something happened, don't ask" of error codes π201β Already paid with this hash using different amount or destination.203β Permanent failure at destination. Thedatafield of the error will be routing failure object (except for self-payment, which currently returns the error directly fromlightning-sendpay(7)).205β Unable to find a route. she looked. she found nothing. π206β Route too expensive. Either the fee or the needed total locktime for the route exceeds yourmaxfeepercentormaxdelaysettings, respectively. Thedatafield of the error will indicate the actual fee as well as thefeepercentpercentage that the fee has of the destination payment amount. It will also indicate the actual delay along the route.207β Invoice expired. Payment took too long before expiration, or already expired at the time you initiated payment. Thedatafield of the error indicatesnow(the current time) andexpiry(the invoice expiration) as UNIX epoch time in seconds. RIP to that invoice π210β Payment timed out without a payment in progress.
Error codes 202 and 204 will only get reported at sendpay; in pay we will keep retrying if we would have gotten those errors. she's stubborn like that π₯
A routing failure object has the fields below:
erring_index: The index of the node along the route that reported the error.0for the local node,1for the first hop, and so on.erring_node: The hex string of the pubkey id of the node that reported the error.erring_channel: The short channel ID of the channel that has the error, or0:0:0if the destination node raised the error.failcode: The failure code, as per BOLT #4.channel_update: The hex string of thechannel_updatemessage received from the remote node. Only present if error is from the remote node and thefailcodehas the UPDATE bit set, as per BOLT #4.
The data field of errors will include statistics getroute_tries and sendpay_tries. It will also contain a failures field with detailed data about routing errors. receipts for your pain π
π AUTHOR π
Rusty Russell rusty@rustcorp.com.au is mainly responsible. ty king π
β SEE ALSO β
lightning-xpay(7), lightning-listpays(7), lightning-decode(7), lightning-listinvoices(7), lightning-delinvoice(7), lightning-getroute(7), lightning-invoice(7) β the whole friend group, go say hi π
π§ RESOURCES π§
Main web site: https://github.com/ElementsProject/lightning
π EXAMPLES π
Example 1
Request:
$ lightning-cli pay "lnbcrt100n1pnt2bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000"
{
"id": "example:pay#1",
"method": "pay",
"params": [
"lnbcrt100n1pnt2bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000"
]
}
Response:
{
"destination": "nodeid030303030303030303030303030303030303030303030303030303030303",
"payment_hash": "paymenthashinvl0320032003200320032003200320032003200320032003200",
"created_at": 1738000000,
"parts": 1,
"amount_msat": 50000,
"amount_sent_msat": 50001,
"payment_preimage": "paymentpreimagep010101010101010101010101010101010101010101010101",
"status": "complete"
}
Example 2
Request:
$ lightning-cli pay -k "bolt11"="lnbcrt100n1pnt2bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000"
{
"id": "example:pay#2",
"method": "pay",
"params": {
"bolt11": "lnbcrt100n1pnt2bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000"
}
}
Response:
{
"destination": "nodeid030303030303030303030303030303030303030303030303030303030303",
"payment_hash": "paymenthashinvl0330033003300330033003300033003300330033003300",
"created_at": 1738000000,
"parts": 1,
"amount_msat": 100000,
"amount_sent_msat": 100000,
"payment_preimage": "paymentpreimagep020202020202020202020202020202020202020202020202",
"status": "complete"
}
and that's the page, bestie!! this lil doc shipped with Core Lightning v26.06.9, and it's dated in the footer the way all manpages are β so when you see LIGHTNING-PAY(7) up top and that version line down at the bottom, that's just the page doing its iconic little bookend thing π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: clightning 26.06.9
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms