lightning-sendonion -- Send a payment with a custom onion packet
SYNOPSIS
sendonion onion first_hop payment_hash [label] [shared_secrets] [partid] [bolt11] [amount_msat] [destination] [localinvreqid] [groupid] [description]
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 are not directly supported by Core Lightning.
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. The following is an example of a 3 hop onion:
[
"298606954e9de3e9d938d18a74fed794c440e8eda82e52dc08600953c8acf9c4",
"2dc094de72adb03b90894192edf9f67919cb2691b37b1f7d4a2f4f31c108b087",
"a7b82b240dbd77a4ac8ea07709b1395d8c510c73c17b4b392bb1f0605d989c85"
]
- onion (hex): 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 for further details. If is specific to the route that is being used and the payment_hash 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. - first_hop (object): Instructs Core Lightning which peer to send the onion to. It is a JSON dictionary that corresponds to the first element of the route array returned by getroute.:
- id (pubkey): Node id for the peer. Use any available channel available to this peer.
- amount_msat (msat): The amount to add an HTLC for millisatoshis.
- delay (u16): The number of blocks delay of blocks on top of the current blockheight.
- payment_hash (hash): Specifies the 32 byte hex-encoded hash to use as 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.
- label (string, optional): Can be used to provide a human readable reference to retrieve the payment at a later time.
- shared_secrets (array of secrets, optional): A JSON list of 32 byte hex-encoded secrets that were used when creating the onion. Core Lightning can send a payment with a 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 shared secrets used in the onion. If shared_secrets is provided Core Lightning 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 correctly. If it is not provided Core Lightning will store the encrypted onion, and expose it in listsendpays allowing the caller to decrypt it externally. If it is not provided the Core Lightning node does not know how 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.:- (secret, optional)
- partid (u16, optional): If provided and non-zero, allows for multiple parallel partial payments with the same payment_hash.
- bolt11 (string, optional): If provided, it will be returned in waitsendpay and listsendpays results.
- amount_msat (msat, optional): Used to annotate the payment, and is returned by waitsendpay and listsendpays.
- destination (pubkey, optional): If provided, it will be returned in listpays result.
- localinvreqid (hash, optional):
localinvreqid
is used by offers to link a payment attempt to a localinvoice_request
offer created by lightningd-invoicerequest(7). - groupid (u64, optional): Grouping key to disambiguate multiple attempts to pay an invoice or the same payment_hash.
- description (string, optional): If provided, it will be returned in waitsendpay and listsendpays results. (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 for created_index.
- payment_hash (hash): The hash of the payment_preimage which 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.
- amount_msat (msat, optional): The amount delivered to destination (if known).
- 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).
- partid (u64, optional): The partid (if supplied) to sendonion/sendpay.
If status is "complete":
- payment_preimage (secret): The proof of payment: SHA256 of this payment_hash.
- updated_index (u64, optional): 1-based index indicating order this payment was changed. (added v23.11)
If status is "pending":
- message (string, optional): Monitor status with listpays or waitsendpay.
ERRORS
The following error codes may occur:
- 202: an parseable onion
the error details are decrypted and presented here, if shared_secrets was provided and an error was returned by one of the intermediate nodes
AUTHOR
Christian Decker <[email protected]> is mainly responsible.
SEE ALSO
lightning-createonion(7), lightning-sendpay(7), lightning-listsendpays(7)
RESOURCES
Main web site: https://github.com/ElementsProject/lightning
EXAMPLES
Example 1:
Request:
lightning-cli sendonion -k "onion"="0003ccc1f8876af4810e23bd4cccd8f2f38ee5dc117f527c783fefa4e632f857c98d588d2e3150d16b78f9458777502e4829b490e8a2d560841eb0c2368311bf9bb4e8ded0356badafd915839409ad60866c24dd7580b468c14097575565ca95425b9f44211d9ad0305ddba2391a70892ac8c9fd7c3b67d0fe22faf5a0b6905ee2e22278fe224e89ea72c3fcc598b35afaa255123e61ae7a697703e3bb8aec4d36ea487df6ec27942aadff0527d178c897e75f1ee284995196b5ead963ee9d0df798c8265c00c5c73daac917d298cc17e5d813189321d914c45ef30170c4d617dae12bb3a760d1665705e61bb6c52789e15623cefc68d96b86a6f17159c4a86bb196c9f5e40a0744d08d6da0cfd587717b6d0d074d42ac0893fa6ae1497c84824f1d27670d4e201af5e9e5a3493b603cfc209bb0ee41b573ca647c5b9882272c972cd18f19fd895e8995097d86882a473f4d26118a7ed656c5ea04c2a183b05cc0191d07fab5e78edab4ab8ec58e05e03f32d150449c0c8e3505e46ae58e77c87616144873f72f4571b00ccf8e71bcdf33a7d32345aecb660970fa73c4844ab157aa322f140f5d47b66a0590273728ddb5b8a7f3577cff5a268935b93fe598d6df4413c67c45efa9461abaf3294070a484418aa28c03ac20d08856eb0c74dfca851e8ed110bdcacb2a2fb90954b04e99986fde0678846a709120b5d1eeab9cde8d9f27d77448f4591e00bf30d7580703e6c189c658746cf7a7cc1430ce41f84244612b438c3d895333848e5f55e99b2a9d28860863c11aaa8e3ef01ead7ba1545156c356424c33aeeaa2f1e2c290d1d8dd52cd7b8116159025aba26db6fb81ad7f9cc4554c6f9f13d16defe38918b32d62a0516521934a0009a8d37c9a84689bfd8fc1f0beceb92701dca11175e0099d7541698956ba5d93efff996f538ee47717ae6c5cda98111bc28c822e99cf8957b707de270f447b6e52d30bcf9b8a9befd8663bc54612b543d0e167da67e2f295207b70857d0a7cae8932d905db2f48c873dec20aeafa07e15fa98a088e529424c8b404f03ba0ee78a6639fde5cd37dee42877ff6489ce1de5a8992cae25dd20a6521955c19129fdcc0ea157913373bf47a8018a1dd825a2f8e26194d5008161360ae9b25fc701b2accbe88eb47eee6a50b7ee6d6e169e3905e03ca72e00eb6a51b7ed3d27501715428368662b822e2262749d3e7d3243c4fd3d825b3e72bebdeebf6e035f1ad6634523ab5dc0335611c19c9936d006f2e4cd8818eb4f8b4857c8f35d18a4891e35ff91e3b54b384398574d673fcc8da50b22b8f485a41223c97e3b8ee5b8e5ff9c00a2cbfe7360509d3fee9248b5eaa81bb83da3be45dfa8cbbbf5c52ba8749c9d6261d4239feea1e7ce85ad40ad0c66bbeb1c6898626ae4e710a66f9c39a5ee94581353b46e070cfcff9a14e3f9a6108d55bb92852eb3a50e89b1e45d31b760f2a4e263a6a876ad638b123ffee7a2b0b48e16175e3eb92bfaad4dbe0af8b2bc1c15fec5a9d92d3970c2ffab2ab8fa2c9de0bd276680a4284707cd8543a97bca2394e9514236129f1c50a932f7e9bfb98c2aaa6ffc9a4a30641061246de6edf0f711a8d25d59af42ee4445b22ce2f832f3ece52c18ca62d90c590729e04c47accaec95b556ee2541c84843c54a116f5cc45bc251a8023b695f0bf79c43a97bece8a761d387a466821984fb5ec438af20d14cebb7f0026988c81b5a1b895ef94df61aa509e53083b4306c42132b5ce302fd5a2fbb1cee30a7078ccaa3bdccf781b8c9d6ae016a5f8e5cb13f7ac1f3fd0d74a182c9abea67d346f0dfcfc211aaa7ff47196465398fce3e6e0f3b73a944a7f57a90cc6a8f1bfcd385f8312e23af6f508f4f8a976d750660ac3d63630555a3a2e7fe158a982aaf0278d9f8819e5cb" "first_hop"='{"id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59", "channel": "109x1x1", "direction": 1, "amount_msat": 1002, "delay": 21, "style": "tlv"}' "payment_hash"="e445ebcf339db3cba6184330ccc6e4a41e0bb38d237b93c1d2f71958d5a74e13"
{
"id": "example:sendonion#1",
"method": "sendonion",
"params": {
"onion": "0003ccc1f8876af4810e23bd4cccd8f2f38ee5dc117f527c783fefa4e632f857c98d588d2e3150d16b78f9458777502e4829b490e8a2d560841eb0c2368311bf9bb4e8ded0356badafd915839409ad60866c24dd7580b468c14097575565ca95425b9f44211d9ad0305ddba2391a70892ac8c9fd7c3b67d0fe22faf5a0b6905ee2e22278fe224e89ea72c3fcc598b35afaa255123e61ae7a697703e3bb8aec4d36ea487df6ec27942aadff0527d178c897e75f1ee284995196b5ead963ee9d0df798c8265c00c5c73daac917d298cc17e5d813189321d914c45ef30170c4d617dae12bb3a760d1665705e61bb6c52789e15623cefc68d96b86a6f17159c4a86bb196c9f5e40a0744d08d6da0cfd587717b6d0d074d42ac0893fa6ae1497c84824f1d27670d4e201af5e9e5a3493b603cfc209bb0ee41b573ca647c5b9882272c972cd18f19fd895e8995097d86882a473f4d26118a7ed656c5ea04c2a183b05cc0191d07fab5e78edab4ab8ec58e05e03f32d150449c0c8e3505e46ae58e77c87616144873f72f4571b00ccf8e71bcdf33a7d32345aecb660970fa73c4844ab157aa322f140f5d47b66a0590273728ddb5b8a7f3577cff5a268935b93fe598d6df4413c67c45efa9461abaf3294070a484418aa28c03ac20d08856eb0c74dfca851e8ed110bdcacb2a2fb90954b04e99986fde0678846a709120b5d1eeab9cde8d9f27d77448f4591e00bf30d7580703e6c189c658746cf7a7cc1430ce41f84244612b438c3d895333848e5f55e99b2a9d28860863c11aaa8e3ef01ead7ba1545156c356424c33aeeaa2f1e2c290d1d8dd52cd7b8116159025aba26db6fb81ad7f9cc4554c6f9f13d16defe38918b32d62a0516521934a0009a8d37c9a84689bfd8fc1f0beceb92701dca11175e0099d7541698956ba5d93efff996f538ee47717ae6c5cda98111bc28c822e99cf8957b707de270f447b6e52d30bcf9b8a9befd8663bc54612b543d0e167da67e2f295207b70857d0a7cae8932d905db2f48c873dec20aeafa07e15fa98a088e529424c8b404f03ba0ee78a6639fde5cd37dee42877ff6489ce1de5a8992cae25dd20a6521955c19129fdcc0ea157913373bf47a8018a1dd825a2f8e26194d5008161360ae9b25fc701b2accbe88eb47eee6a50b7ee6d6e169e3905e03ca72e00eb6a51b7ed3d27501715428368662b822e2262749d3e7d3243c4fd3d825b3e72bebdeebf6e035f1ad6634523ab5dc0335611c19c9936d006f2e4cd8818eb4f8b4857c8f35d18a4891e35ff91e3b54b384398574d673fcc8da50b22b8f485a41223c97e3b8ee5b8e5ff9c00a2cbfe7360509d3fee9248b5eaa81bb83da3be45dfa8cbbbf5c52ba8749c9d6261d4239feea1e7ce85ad40ad0c66bbeb1c6898626ae4e710a66f9c39a5ee94581353b46e070cfcff9a14e3f9a6108d55bb92852eb3a50e89b1e45d31b760f2a4e263a6a876ad638b123ffee7a2b0b48e16175e3eb92bfaad4dbe0af8b2bc1c15fec5a9d92d3970c2ffab2ab8fa2c9de0bd276680a4284707cd8543a97bca2394e9514236129f1c50a932f7e9bfb98c2aaa6ffc9a4a30641061246de6edf0f711a8d25d59af42ee4445b22ce2f832f3ece52c18ca62d90c590729e04c47accaec95b556ee2541c84843c54a116f5cc45bc251a8023b695f0bf79c43a97bece8a761d387a466821984fb5ec438af20d14cebb7f0026988c81b5a1b895ef94df61aa509e53083b4306c42132b5ce302fd5a2fbb1cee30a7078ccaa3bdccf781b8c9d6ae016a5f8e5cb13f7ac1f3fd0d74a182c9abea67d346f0dfcfc211aaa7ff47196465398fce3e6e0f3b73a944a7f57a90cc6a8f1bfcd385f8312e23af6f508f4f8a976d750660ac3d63630555a3a2e7fe158a982aaf0278d9f8819e5cb",
"first_hop": {
"id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
"channel": "109x1x1",
"direction": 1,
"amount_msat": 1002,
"delay": 21,
"style": "tlv"
},
"payment_hash": "e445ebcf339db3cba6184330ccc6e4a41e0bb38d237b93c1d2f71958d5a74e13"
}
}
Response:
{
"message": "Monitor status with listpays or waitsendpay",
"created_index": 8,
"id": 8,
"payment_hash": "e445ebcf339db3cba6184330ccc6e4a41e0bb38d237b93c1d2f71958d5a74e13",
"groupid": 1,
"amount_sent_msat": 1002,
"created_at": 1722303689,
"status": "pending"
}