LIGHTNING-SENDPAY(7)
β¨ NAME β¨
sendpay β low-level command for sending a payment via a route.
This is the LIGHTNING-SENDPAY(7) manual, bestie. Low-level route-payment tea, coming right up. π«Ά
π¦ SYNOPSIS π¦
sendpay route payment_hash [label] [amount_msat] [bolt11]
[payment_secret] [partid] [localinvreqid] [groupid] [payment_metadata]
[description]
π DESCRIPTION π
The sendpay RPC command attempts to send funds associated with the given payment_hash, along a route to the final destination in the route.
Generally, a client would call lightning-getroute(7) or lightning-getroutes(7) to resolve a route, then use sendpay to send it. This is why sendpay's route ignores unknown members: it uses the fields from either of those commands and ignored others. If it fails, it would call lightning-getroutes(7) again to retry. If the route is empty, a payment-to-self is attempted.
The response will occur when the payment is on its way to the destination. The sendpay RPC command does not wait for definite success or definite failure of the payment (except for already-succeeded payments, or to-self payments). Instead, use the waitsendpay RPC command to poll or wait for definite success or definite failure.
π Important bestie warning: once a payment has succeeded, calls tosendpaywith the samepayment_hashbut a differentamount_msator destination will fail; this prevents accidental multiple payments. Calls tosendpaywith the samepayment_hash,amount_msat, and destination as a previous successful payment (even if a differentrouteorpartid) will return immediately with success.
Here are the params, slayfully listed:
route(array of objects) β here's what can go in each object:short_channel_id_dir(short_channel_id_dir, optional): The channel joining these nodes. (added v26.06)node_id_out(pubkey, optional): The node at the end of this hop. (added v26.06)amount_out_msat(msat, optional): The amount expected at the far end of this hop. (added v26.06)cltv_out(u32, optional): The total CLTV expected by the node at the end of this hop. (added v26.06)id(pubkey, optional): The node at the end of this hop (older name fornode_id_out).channel(short_channel_id, optional): The channel joining these nodes (older name forshort_channel_id_dir)delay(u32, optional): The total CLTV expected by the node at the end of this hop (older name forcltv_out).amount_msat(msat, optional): The amount expected by the node at the end of this hop (older name foramount_out_msat).
payment_hash(hash): The hash of thepayment_preimage.label(string, optional): The label provided when creating theinvoice_request.amount_msat(msat, optional): Amount must be provided ifpartidis non-zero, or the payment is to-self, otherwise it must be equal to the final amount to the destination. it can be a whole number, or a whole number ending inmsatorsat, or a number with three decimal places ending insat, or a number with 1 to 11 decimal places ending inbtc. The default is in millisatoshi precision.bolt11(string, optional): Bolt11 invoice to pay. If provided, will be returned inwaitsendpayandlistsendpaysresults.payment_secret(secret, optional): Value that the final recipient requires to accept the payment, as defined by thepayment_datafield in BOLT 4 and thesfield in the BOLT 11 invoice format. It is required ifpartidis non-zero.partid(u64, optional): Must not be provided for self-payments. If provided and non-zero, allows for multiple parallel partial payments with the samepayment_hash. Theamount_msatamount (which must be provided) for eachsendpaywith matchingpayment_hashmust be equal, andsendpaywill fail if there are differing values given.localinvreqid(hex, optional): Indicates that this payment is being made for a localinvoice_request. This ensures that we only send a payment for a single-useinvoice_requestonce.groupid(u64, optional): Allows you to attach a number which appears inlistsendpaysso payments can be identified as part of a logical group. Thepayplugin uses this to identify one attempt at a MPP payment, for example.payment_metadata(hex, optional): Placed in the final onion hop TLV. (added v0.11.0)description(string, optional): Description used in the invoice. (added v0.11.0)
πΈ RETURN VALUE πΈ
On success, an object is returned, containing:
created_index(u64): 1-based index indicating order this payment was created in. (added v23.11)id(u64): Old synonym forcreated_index.payment_hash(hash): The hash of thepayment_preimagewhich will prove payment.status(string) (one of"pending","complete"): Status of the payment (could be complete if already sent previously).created_at(u64): The UNIX timestamp showing when this payment was initiated.amount_sent_msat(msat): The amount sent.updated_index(u64, optional): 1-based index indicating order this payment was changed (only present if it has changed since creation). (added v23.11)groupid(u64, optional): Grouping key to disambiguate multiple attempts to pay an invoice or the samepayment_hash.amount_msat(msat, optional): The amount delivered to destination (if known).destination(pubkey, optional): The final destination of the payment if known.completed_at(u64, optional): The UNIX timestamp showing when this payment was completed.label(string, optional): The label, if given tosendpay.partid(u64, optional): Thepartid, if given tosendpay.bolt11(string, optional): The bolt11 string (if supplied).bolt12(string, optional): The bolt12 string (if supplied).
If status is "complete":
payment_preimage(secret): The proof of payment: SHA256 of thispayment_hash.
If status is "pending":
message(string): Monitor status withlistpaysorwaitsendpay.
π ERRORS π
On error, if the error occurred from a node other than the final destination, the route table will be updated so that lightning-getroute(7) should return an alternate route (if any). An error from the final destination implies the payment should not be retried.
-1: Catchall nonspecific error.201: Already paid with this hash using different amount or destination.202: Unparseable onion reply. Thedatafield of the error will have anonionreplyfield, a hex string representation of the raw onion reply.203: Permanent failure at destination. Thedatafield of the error will be routing failure object.204: Failure along route; retry a different route. Thedatafield of the error will be routing failure object.212:localinvreqidrefers to an invalid, or used, localinvoice_request.
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. In additionerring_directionwill indicate which direction of the channel caused the failure.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.
π AUTHOR π
Rusty Russell rusty@rustcorp.com.au is mainly responsible. Iconic. π
π₯ SEE ALSO π₯
Go read these too, bestie:
lightning-listinvoices(7)lightning-delinvoice(7)lightning-getroute(7)lightning-invoice(7)lightning-xpay(7)lightning-waitsendpay(7)
π RESOURCES π
Main web site: https://github.com/ElementsProject/lightning
π EXAMPLES π
Example 1:
Request:
$ lightning-cli sendpay -k "route"='[{"id": "nodeid020202020202020202020202020202020202020202020202020202020202", "channel": "109x1x1", "direction": 1, "amount_msat": 10001, "delay": 15, "style": "tlv"}, {"id": "nodeid030303030303030303030303030303030303030303030303030303030303", "channel": "111x1x1", "direction": 0, "amount_msat": 10000, "delay": 9, "style": "tlv"}]' "payment_hash"="paymenthashinvl0310031003100310031003100310031003100310031003100" "payment_secret"="paymentsecretinvl00310003100031000310003100031000310003100031000"
{
"id": "example:sendpay#1",
"method": "sendpay",
"params": {
"route": [
{
"id": "nodeid020202020202020202020202020202020202020202020202020202020202",
"channel": "109x1x1",
"direction": 1,
"amount_msat": 10001,
"delay": 15,
"style": "tlv"
},
{
"id": "nodeid030303030303030303030303030303030303030303030303030303030303",
"channel": "111x1x1",
"direction": 0,
"amount_msat": 10000,
"delay": 9,
"style": "tlv"
}
],
"payment_hash": "paymenthashinvl0310031003100310031003100310031003100310031003100",
"payment_secret": "paymentsecretinvl00310003100031000310003100031000310003100031000"
}
}
Response:
{
"message": "Monitor status with listpays or waitsendpay",
"created_index": 2,
"id": 2,
"payment_hash": "paymenthashinvl0310031003100310031003100310031003100310031003100",
"groupid": 1,
"destination": "nodeid030303030303030303030303030303030303030303030303030303030303",
"amount_msat": 10000,
"amount_sent_msat": 10001,
"created_at": 1738000000,
"status": "pending"
}
π Cute sign-off: Core Lightning v26.06.9 Β· LIGHTNING-SENDPAY(7) Β· that's the footer tea β no date listed, so we're not making one up. Stay paid, bestie. πβ¨
π¦ 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