2019-08-31 14:30:56 +02:00
lightning-sendpay -- Low-level command for sending a payment via a route
========================================================================
2019-08-10 01:54:18 +02:00
SYNOPSIS
--------
2022-12-10 09:10:19 +01:00
**sendpay** *route* *payment\_hash* [*label*] [*amount\_msat*]
2022-11-11 02:44:56 +01:00
[*bolt11*] [*payment\_secret*] [*partid*] [*localinvreqid*] [*groupid*]
[*payment\_metadata*] [*description*]
2019-08-10 01:54:18 +02:00
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) to resolve a route,
then use **sendpay** to send it. If it fails, it would call
2023-07-22 13:26:27 +02:00
lightning-getroute(7) again to retry. If the route is empty, a payment-to-self is attempted.
2019-08-10 01:54:18 +02:00
The response will occur when the payment is on its way to the
destination. The **sendpay** RPC command does not wait for definite
2023-07-22 13:26:27 +02:00
success or definite failure of the payment (except for already-succeeded
payments, or to-self payments). Instead, use the
2019-08-10 01:54:18 +02:00
**waitsendpay** RPC command to poll or wait for definite success or
definite failure.
The *label* and *bolt11* parameters, if provided, will be returned in
*waitsendpay* and *listsendpays* results.
2023-07-22 13:26:27 +02:00
The *amount\_msat* amount must be provided if *partid* is non-zero, or the payment is to-self, otherwise
2020-01-30 03:02:37 +01:00
it must be equal to the final
2019-12-12 11:57:07 +01:00
amount to the destination. By default it is in millisatoshi precision; it can be a whole number, or a whole number
2019-08-10 01:54:18 +02:00
ending in *msat* or *sat* , or a number with three decimal places ending
in *sat* , or a number with 1 to 11 decimal places ending in *btc* .
2022-11-11 02:44:56 +01:00
The *payment\_secret* is the value that the final recipient requires to
2020-07-21 06:22:56 +02:00
accept the payment, as defined by the `payment_data` field in BOLT 4
and the `s` field in the BOLT 11 invoice format. It is required if
*partid* is non-zero.
2023-07-22 13:26:27 +02:00
The *partid* value must not be provided for self-payments. If provided and non-zero, allows for multiple parallel
2022-12-10 09:10:19 +01:00
partial payments with the same *payment\_hash* . The *amount\_msat* amount
2019-12-12 11:57:07 +01:00
(which must be provided) for each **sendpay** with matching
2023-07-22 13:26:27 +02:00
*payment\_hash* must be equal, and **sendpay** will fail if there are differing values given.
2019-12-12 11:57:07 +01:00
2022-11-09 03:32:01 +01:00
The *localinvreqid* value indicates that this payment is being made for a local
2022-11-11 02:44:56 +01:00
invoice\_request: this ensures that we only send a payment for a single-use
invoice\_request once.
2022-03-31 11:10:50 +02:00
*groupid* allows you to attach a number which appears in **listsendpays** so
payments can be identified as part of a logical group. The *pay* plugin uses
this to identify one attempt at a MPP payment, for example.
2022-11-11 02:44:56 +01:00
*payment\_metadata* is placed in the final onion hop TLV.
2022-03-31 11:10:50 +02:00
2019-08-10 01:54:18 +02:00
Once a payment has succeeded, calls to **sendpay** with the same
2022-12-10 09:10:19 +01:00
*payment\_hash* but a different *amount\_msat* or destination will fail;
2019-08-10 01:54:18 +02:00
this prevents accidental multiple payments. Calls to **sendpay** with
2022-12-10 09:10:19 +01:00
the same *payment\_hash* , *amount\_msat* , and destination as a previous
2019-12-12 11:57:07 +01:00
successful payment (even if a different route or *partid* ) will return immediately
2019-08-10 01:54:18 +02:00
with success.
RETURN VALUE
------------
2021-06-16 03:10:17 +02:00
[comment]: # (GENERATE-FROM-SCHEMA-START)
On success, an object is returned, containing:
2022-09-05 23:33:09 +02:00
2023-10-28 05:09:15 +02:00
- **created\_index** (u64): 1-based index indicating order this payment was created in *(added v23.11)*
- **id** (u64): old synonym for created\_index
2023-01-30 07:24:16 +01:00
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment
2021-06-16 03:10:17 +02:00
- **status** (string): status of the payment (could be complete if already sent previously) (one of "pending", "complete")
2022-09-05 23:45:06 +02:00
- **created\_at** (u64): the UNIX timestamp showing when this payment was initiated
- **amount\_sent\_msat** (msat): The amount sent
2023-10-28 05:09:15 +02:00
- **updated\_index** (u64, optional): 1-based index indicating order this payment was changed (only present if it has changed since creation) *(added v23.11)*
2022-11-11 03:03:13 +01:00
- **groupid** (u64, optional): Grouping key to disambiguate multiple attempts to pay an invoice or the same payment\_hash
2022-09-05 23:45:06 +02:00
- **amount\_msat** (msat, optional): The amount delivered to destination (if known)
2021-06-16 03:10:17 +02:00
- **destination** (pubkey, optional): the final destination of the payment if known
2022-06-09 18:36:00 +02:00
- **completed\_at** (u64, optional): the UNIX timestamp showing when this payment was completed
2021-06-16 03:10:17 +02:00
- **label** (string, optional): the *label* , if given to sendpay
- **partid** (u64, optional): the *partid* , if given to sendpay
- **bolt11** (string, optional): the bolt11 string (if supplied)
- **bolt12** (string, optional): the bolt12 string (if supplied: **experimental-offers** only).
If **status** is "complete":
2022-09-05 23:33:09 +02:00
2023-01-30 07:24:16 +01:00
- **payment\_preimage** (secret): the proof of payment: SHA256 of this **payment\_hash**
2021-06-16 03:10:17 +02:00
If **status** is "pending":
2022-09-05 23:33:09 +02:00
2021-06-16 03:10:17 +02:00
- **message** (string): Monitor status with listpays or waitsendpay
2021-09-03 12:07:59 +02:00
2021-06-16 03:10:17 +02:00
[comment]: # (GENERATE-FROM-SCHEMA-END)
2019-08-10 01:54:18 +02:00
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.
The following error codes may occur:
2023-10-14 10:09:05 +02:00
2019-08-10 01:54:18 +02:00
- -1: Catchall nonspecific error.
- 201: Already paid with this *hash* using different amount or
destination.
- 202: Unparseable onion reply. The *data* field of the error will
have an *onionreply* field, a hex string representation of the raw
onion reply.
- 203: Permanent failure at destination. The *data* field of the error
will be routing failure object.
- 204: Failure along route; retry a different route. The *data* field
of the error will be routing failure object.
2022-11-11 02:44:56 +01:00
- 212: *localinvreqid* refers to an invalid, or used, local invoice\_request.
2019-08-10 01:54:18 +02:00
A routing failure object has the fields below:
2023-10-14 10:09:05 +02:00
2019-08-10 01:54:18 +02:00
- *erring\_index* . The index of the node along the route that reported
the error. 0 for the local node, 1 for the first hop, and so on.
- *erring\_node* . The hex string of the pubkey id of the node that
reported the error.
2021-01-08 11:36:02 +01:00
- *erring\_channel* . The short channel ID of the channel that has
the error, or *0:0:0* if the destination node raised the error. In
addition *erring\_direction* will indicate which direction of the
channel caused the failure.
2019-08-10 01:54:18 +02:00
- *failcode* . The failure code, as per BOLT \#4.
- *channel\_update* . The hex string of the *channel\_update* message
received from the remote node. Only present if error is from the
remote node and the *failcode* has the UPDATE bit set, as per BOLT
\#4.
AUTHOR
------
Rusty Russell < < rusty @ rustcorp . com . au > > is mainly responsible.
SEE ALSO
--------
lightning-listinvoice(7), lightning-delinvoice(7),
lightning-getroute(7), lightning-invoice(7), lightning-pay(7),
lightning-waitsendpay(7).
RESOURCES
---------
Main web site: < https: / / github . com / ElementsProject / lightning >
2020-08-25 03:33:16 +02:00
2023-10-28 05:09:15 +02:00
[comment]: # ( SHA256STAMP:e7c592d2b7312bdf39af6c64d813819ac3e629670acbb5d07e83fb9eaa8222f5)