2019-11-14 17:51:28 +01:00
|
|
|
lightning-createonion -- Low-level command to create a custom onion
|
|
|
|
===================================================================
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
**createonion** *hops* *assocdata* [*session\_key*] [*onion\_size*]
|
2019-11-14 17:51:28 +01:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
|
|
|
The **createonion** RPC command allows the caller to create a custom onion
|
|
|
|
with custom payloads at each hop in the route. A custom onion can be used to
|
2022-04-06 07:09:48 +02:00
|
|
|
implement protocol extensions that are not supported by Core Lightning directly.
|
2019-11-14 17:51:28 +01:00
|
|
|
|
|
|
|
The *hops* parameter is a JSON list of dicts, each specifying a node and the
|
|
|
|
payload destined for that node. The following is an example of a 3 hop onion:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"pubkey": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
|
2022-09-28 06:49:37 +02:00
|
|
|
"payload": "11020203e904017b06080000670000010001"
|
2019-11-14 17:51:28 +01:00
|
|
|
}, {
|
|
|
|
"pubkey": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d",
|
2022-09-28 06:49:37 +02:00
|
|
|
"payload": "11020203e804017506080000670000030001"
|
2019-11-14 17:51:28 +01:00
|
|
|
}, {
|
|
|
|
"pubkey": "0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199",
|
2022-09-28 06:49:37 +02:00
|
|
|
"payload": "07020203e8040175"
|
2019-11-14 17:51:28 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
The *hops* parameter is very similar to the result from `getroute` however it
|
|
|
|
needs to be modified slightly. The following is the `getroute` response from
|
|
|
|
which the above *hops* parameter was generated:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
|
|
|
|
"channel": "103x2x1",
|
|
|
|
"direction": 1,
|
|
|
|
"msatoshi": 1002,
|
|
|
|
"amount_msat": "1002msat",
|
|
|
|
"delay": 21,
|
|
|
|
}, {
|
|
|
|
"id": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d",
|
|
|
|
"channel": "103x1x1",
|
|
|
|
"direction": 0,
|
|
|
|
"msatoshi": 1001,
|
|
|
|
"amount_msat": "1001msat",
|
|
|
|
"delay": 15,
|
|
|
|
}, {
|
|
|
|
"id": "0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199",
|
|
|
|
"channel": "103x3x1",
|
|
|
|
"direction": 0,
|
|
|
|
"msatoshi": 1000,
|
|
|
|
"amount_msat": "1000msat",
|
|
|
|
"delay": 9,
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2022-09-28 06:49:37 +02:00
|
|
|
- Notice that the payload in the *hops* parameter is the hex-encoded TLV
|
|
|
|
of the parameters in the `getroute` response, with length prepended as a `bigsize_t`.
|
2021-05-10 05:55:04 +02:00
|
|
|
- Except for the pubkey, the values are shifted left by one, i.e., the 1st
|
|
|
|
payload in `createonion` corresponds to the 2nd set of values from `getroute`.
|
2019-11-14 17:51:28 +01:00
|
|
|
- The final payload is a copy of the last payload sans `channel`
|
2021-05-10 05:55:04 +02:00
|
|
|
|
2019-11-14 17:51:28 +01:00
|
|
|
These rules are directly derived from the onion construction. Please refer
|
2022-06-30 07:48:56 +02:00
|
|
|
[BOLT 04](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for details and rationale.
|
2019-11-14 17:51:28 +01:00
|
|
|
|
|
|
|
The *assocdata* parameter specifies the associated data that the onion should
|
|
|
|
commit to. If the onion is to be used to send a payment later it MUST match
|
|
|
|
the `payment_hash` of the payment in order to be valid.
|
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
The optional *session\_key* parameter can be used to specify a secret that is
|
2019-11-14 17:51:28 +01:00
|
|
|
used to generate the shared secrets used to encrypt the onion for each hop. It
|
|
|
|
should only be used for testing or if a specific shared secret is
|
|
|
|
important. If not specified it will be securely generated internally, and the
|
|
|
|
shared secrets will be returned.
|
|
|
|
|
2022-11-11 02:44:56 +01:00
|
|
|
The optional *onion\_size* parameter specifies a size different from the default
|
2021-05-10 05:55:04 +02:00
|
|
|
payment onion (1300 bytes). May be used for custom protocols like trampoline
|
|
|
|
routing.
|
|
|
|
|
2019-11-14 17:51:28 +01:00
|
|
|
RETURN VALUE
|
|
|
|
------------
|
|
|
|
|
2021-05-26 07:50:01 +02:00
|
|
|
[comment]: # (GENERATE-FROM-SCHEMA-START)
|
|
|
|
On success, an object is returned, containing:
|
2022-09-05 23:33:09 +02:00
|
|
|
|
2022-11-11 03:03:13 +01:00
|
|
|
- **onion** (hex): the onion packet (*onion\_size* bytes)
|
2022-09-05 23:45:06 +02:00
|
|
|
- **shared\_secrets** (array of secrets): one shared secret for each node in the *hops* parameter:
|
2023-01-30 07:24:16 +01:00
|
|
|
- the shared secret with this hop
|
2021-09-03 12:07:59 +02:00
|
|
|
|
2021-05-26 07:50:01 +02:00
|
|
|
[comment]: # (GENERATE-FROM-SCHEMA-END)
|
|
|
|
|
|
|
|
EXAMPLE
|
|
|
|
-------
|
|
|
|
|
|
|
|
The following example is the result of calling *createonion* with the
|
|
|
|
above hops parameter:
|
2019-11-14 17:51:28 +01:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2021-10-24 11:44:56 +02:00
|
|
|
"onion": "0003f3f80d2142b953319336d2fe4097[...]6af33fcf4fb113bce01f56dd62248a9e5fcbbfba35c",
|
2019-11-14 17:51:28 +01:00
|
|
|
"shared_secrets": [
|
|
|
|
"88ce98c73e4d9293ab1797b0a913fe9bca0213a566252047d01b8af6da871f3e",
|
|
|
|
"4474d296810e57bd460ef8b83d2e7d288321f8a99ff7686f87384699747bcfc4",
|
|
|
|
"2a862e4123e01799a732be487fbce297f7dc7cc1467e410f18369cfee476adc2"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The `onion` corresponds to 1366 hex-encoded bytes. Each shared secret consists
|
|
|
|
of 32 hex-encoded bytes. Both arguments can be passed on to **sendonion**.
|
|
|
|
|
|
|
|
AUTHOR
|
|
|
|
------
|
|
|
|
|
|
|
|
Christian Decker <<decker.christian@gmail.com>> is mainly responsible.
|
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
|
|
|
|
lightning-sendonion(7), lightning-getroute(7)
|
|
|
|
|
|
|
|
RESOURCES
|
|
|
|
---------
|
|
|
|
|
|
|
|
Main web site: <https://github.com/ElementsProject/lightning>
|
|
|
|
|
2023-01-30 07:24:16 +01:00
|
|
|
[comment]: # ( SHA256STAMP:08d376f24ca65df41645bd82fa8c8d19fa8610fb5e41f252f001845334b68fbb)
|