2019-11-14 17:51:28 +01:00
|
|
|
lightning-sendonion -- Send a payment with a custom onion packet
|
|
|
|
================================================================
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
**sendonion** *onion* *first\_hop* *payment\_hash* [*label*] [*shared\_secrets*] [*partid*] [*bolt11*]
|
2022-12-10 09:10:19 +01:00
|
|
|
[*amount\_msat*] [*destination*]
|
2019-11-14 17:51:28 +01:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
|
|
|
The **sendonion** RPC command can be used to initiate a payment attempt with a
|
|
|
|
custom onion packet. The onion packet is used to deliver instructions for hops
|
|
|
|
along the route on how to behave. Normally these instructions are indications
|
|
|
|
on where to forward a payment and what parameters to use, or contain details
|
|
|
|
of the payment for the final hop. However, it is possible to add arbitrary
|
|
|
|
information for hops in the custom onion, allowing for custom extensions that
|
2022-04-06 07:09:48 +02:00
|
|
|
are not directly supported by Core Lightning.
|
2019-11-14 17:51:28 +01:00
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
The onion is specific to the route that is being used and the *payment\_hash*
|
2019-11-14 17:51:28 +01:00
|
|
|
used to construct, and therefore cannot be reused for other payments or to
|
|
|
|
attempt a separate route. The custom onion can generally be created using the
|
|
|
|
`devtools/onion` CLI tool, or the **createonion** RPC command.
|
|
|
|
|
|
|
|
The *onion* parameter is a hex-encoded 1366 bytes long blob that was returned
|
|
|
|
by either of the tools that can generate onions. It contains the payloads
|
|
|
|
destined for each hop and some metadata. Please refer to [BOLT 04][bolt04] for
|
|
|
|
further details.
|
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
The *first\_hop* parameter instructs Core Lightning which peer to send the onion
|
2019-11-14 17:51:28 +01:00
|
|
|
to. It is a JSON dictionary that corresponds to the first element of the route
|
|
|
|
array returned by *getroute*. The following is a minimal example telling
|
2022-04-06 07:09:48 +02:00
|
|
|
Core Lightning to use any available channel to `022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59`
|
2020-05-13 19:00:36 +02:00
|
|
|
to add an HTLC for 1002 millisatoshis and a delay of 21 blocks on top of the current blockheight:
|
2019-11-14 17:51:28 +01:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-05-13 19:00:36 +02:00
|
|
|
"id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
|
2019-11-14 17:51:28 +01:00
|
|
|
"amount_msat": "1002msat",
|
|
|
|
"delay": 21,
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-08-09 00:19:18 +02:00
|
|
|
If the first element of *route* does not have "channel" set, a
|
|
|
|
suitable channel (if any) will be chosen, otherwise that specific
|
|
|
|
short-channel-id is used.
|
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
The *payment\_hash* parameter specifies the 32 byte hex-encoded hash to use as
|
2019-11-14 17:51:28 +01:00
|
|
|
a challenge to the HTLC that we are sending. It is specific to the onion and
|
|
|
|
has to match the one the onion was created with.
|
|
|
|
|
|
|
|
The *label* parameter can be used to provide a human readable reference to
|
|
|
|
retrieve the payment at a later time.
|
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
The *shared\_secrets* parameter is a JSON list of 32 byte hex-encoded secrets
|
2022-04-06 07:09:48 +02:00
|
|
|
that were used when creating the onion. Core Lightning can send a payment with a
|
2019-11-14 17:51:28 +01:00
|
|
|
custom onion without the knowledge of these secrets, however it will not be
|
|
|
|
able to parse an eventual error message since that is encrypted with the
|
2022-11-11 02:44:56 +01:00
|
|
|
shared secrets used in the onion. If *shared\_secrets* is provided Core Lightning
|
2019-11-14 17:51:28 +01:00
|
|
|
will decrypt the error, act accordingly, e.g., add a `channel_update` included
|
|
|
|
in the error to its network view, and set the details in *listsendpays*
|
2022-04-06 07:09:48 +02:00
|
|
|
correctly. If it is not provided Core Lightning will store the encrypted onion,
|
2019-11-14 17:51:28 +01:00
|
|
|
and expose it in *listsendpays* allowing the caller to decrypt it
|
|
|
|
externally. The following is an example of a 3 hop onion:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
"298606954e9de3e9d938d18a74fed794c440e8eda82e52dc08600953c8acf9c4",
|
|
|
|
"2dc094de72adb03b90894192edf9f67919cb2691b37b1f7d4a2f4f31c108b087",
|
|
|
|
"a7b82b240dbd77a4ac8ea07709b1395d8c510c73c17b4b392bb1f0605d989c85"
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
If *shared\_secrets* is not provided the Core Lightning node does not know how
|
2019-11-14 17:51:28 +01:00
|
|
|
long the route is, which channels or nodes are involved, and what an eventual
|
|
|
|
error could have been. It can therefore be used for oblivious payments.
|
|
|
|
|
2020-07-26 03:07:58 +02:00
|
|
|
The *partid* value, if provided and non-zero, allows for multiple parallel
|
2022-11-11 02:44:56 +01:00
|
|
|
partial payments with the same *payment\_hash*.
|
2020-07-26 03:07:58 +02:00
|
|
|
|
|
|
|
The *bolt11* parameter, if provided, will be returned in
|
|
|
|
*waitsendpay* and *listsendpays* results.
|
|
|
|
|
2020-07-31 17:19:22 +02:00
|
|
|
The *destination* parameter, if provided, will be returned in **listpays** result.
|
|
|
|
|
2022-12-10 09:10:19 +01:00
|
|
|
The *amount\_msat* parameter is used to annotate the payment, and is returned by
|
2020-07-27 21:53:06 +02:00
|
|
|
*waitsendpay* and *listsendpays*.
|
|
|
|
|
2019-11-14 17:51:28 +01:00
|
|
|
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
|
|
|
|
2021-06-16 03:10:17 +02:00
|
|
|
- **id** (u64): unique ID for this payment attempt
|
2022-11-11 03:03:13 +01:00
|
|
|
- **payment\_hash** (hash): the hash of the *payment\_preimage* which will prove payment (always 64 characters)
|
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
|
|
|
|
- **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
|
|
|
|
- **label** (string, optional): the label, if given to sendpay
|
|
|
|
- **bolt11** (string, optional): the bolt11 string (if supplied)
|
|
|
|
- **bolt12** (string, optional): the bolt12 string (if supplied: **experimental-offers** only).
|
2022-03-31 05:11:27 +02:00
|
|
|
- **partid** (u64, optional): the partid (if supplied) to sendonion/sendpay
|
2021-06-16 03:10:17 +02:00
|
|
|
|
|
|
|
If **status** is "complete":
|
2022-09-05 23:33:09 +02:00
|
|
|
|
2022-11-11 03:03:13 +01:00
|
|
|
- **payment\_preimage** (secret): the proof of payment: SHA256 of this **payment\_hash** (always 64 characters)
|
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, optional): 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-11-14 17:51:28 +01:00
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
If *shared\_secrets* was provided and an error was returned by one of the
|
2019-11-14 17:51:28 +01:00
|
|
|
intermediate nodes the error details are decrypted and presented
|
|
|
|
here. Otherwise the error code is 202 for an unparseable onion.
|
|
|
|
|
|
|
|
AUTHOR
|
|
|
|
------
|
|
|
|
|
|
|
|
Christian Decker <<decker.christian@gmail.com>> is mainly responsible.
|
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
|
|
|
|
lightning-createonion(7), lightning-sendpay(7), lightning-listsendpays(7)
|
|
|
|
|
|
|
|
RESOURCES
|
|
|
|
---------
|
|
|
|
|
|
|
|
Main web site: <https://github.com/ElementsProject/lightning>
|
|
|
|
|
2022-09-29 05:49:03 +02:00
|
|
|
[bolt04]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md
|
2023-01-10 00:51:01 +01:00
|
|
|
[comment]: # ( SHA256STAMP:dab3d2111fac44ea7d0183485e6f67566d2c577f9dafde8a897f438fab04e7e6)
|