LIGHTNING-CREATEONION(7)
π
LIGHTNING-CREATEONION(7) β the lightning-createonion manual, but make it make sense π§
β¨
okay so bestie, welcome to LIGHTNING-CREATEONION(7), the lowkey advanced corner of the Core Lightning docs. buckle up π«Ά
β¨ NAME β¨
createonion β the low-level command that lets you build a custom onion, by hand, like the main character you are π§
π
πΈ SYNOPSIS πΈ
createonion hops assocdata [session_key] [onion_size]
π¦ DESCRIPTION π¦
okay so the createonion RPC command is the one that lets you β the caller β cook up a custom onion with custom payloads at every single hop along the route. it's giving DIY. and the whole point? a custom onion lets you implement protocol extensions that Core Lightning doesn't support directly. iykyk π
hops(array of objects) β a JSON list of dicts, each one specifying a node and the payload destined for that node:pubkey(pubkey) β the node's pubkey.payload(hex) β the payload to be sent to that node.
assocdata(hex) β the associated data that the onion should commit to. important king: if the onion is gonna be used to send a payment later, it MUST match thepayment_hashof the payment in order to be valid. no cap, it has to match.session_key(secret, optional) β you can use this to specify a secret that's 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 you don't specify it, it'll be securely generated internally β and the shared secrets will be returned to you. slay.onion_size(u16, optional) β a size different from the default payment onion (1300bytes). may be used for custom protocols like trampoline routing. cute for special occasions π
π RETURN VALUE π
on success, an object is returned, containing:
onion(hex) β the onion packet (onion_sizebytes). the whole vibe in one blob π§shared_secrets(array of secrets) β one shared secret for each node in thehopsparameter:- (secret, optional) β the shared secret with this hop.
π AUTHOR π
Christian Decker <decker.christian@gmail.com> is mainly responsible. we stan. π«Ά
π SEE ALSO π
lightning-sendonion(7), lightning-getroute(7)
β RESOURCES β
Main web site: https://github.com/ElementsProject/lightning
BOLT 04
π EXAMPLES π
Example 1:
Request:
$ lightning-cli createonion -k "hops"='[{"pubkey": "nodeid020202020202020202020202020202020202020202020202020202020202", "payload": "payload010101010101010101010101010"}, {"pubkey": "nodeid030303030303030303030303030303030303030303030303030303030303", "payload": "payload020202020202020202020202020"}, {"pubkey": "nodeid040404040404040404040404040404040404040404040404040404040404", "payload": "payload030303030303030303030303030"}]' "assocdata"="assocdata0010101010101010101010101010101010101010101010101010101"
{
"id": "example:createonion#1",
"method": "createonion",
"params": {
"hops": [
{
"pubkey": "nodeid020202020202020202020202020202020202020202020202020202020202",
"payload": "payload010101010101010101010101010"
},
{
"pubkey": "nodeid030303030303030303030303030303030303030303030303030303030303",
"payload": "payload020202020202020202020202020"
},
{
"pubkey": "nodeid040404040404040404040404040404040404040404040404040404040404",
"payload": "payload030303030303030303030303030"
}
],
"assocdata": "assocdata0010101010101010101010101010101010101010101010101010101"
}
}
Response:
{
"onion": "onion10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010",
"shared_secrets": [
"sharedsecret1010101010101010101010101010101010101010101010101010",
"sharedsecret1111111111111111111111111111111111111111111111111111",
"sharedsecret1212121212121212121212121212121212121212121212121212"
]
}
Example 2:
Request:
$ lightning-cli createonion -k "hops"='[{"pubkey": "nodeid020202020202020202020202020202020202020202020202020202020202", "payload": "payload010101010101010101010101010"}, {"pubkey": "nodeid030303030303030303030303030303030303030303030303030303030303", "payload": "payload020202020202020202020202020"}, {"pubkey": "nodeid040404040404040404040404040404040404040404040404040404040404", "payload": "payload030303030303030303030303030"}]' "assocdata"="assocdata0010101010101010101010101010101010101010101010101010101" "session_key"="4141414141414141414141414141414141414141414141414141414141414141"
{
"id": "example:createonion#2",
"method": "createonion",
"params": {
"hops": [
{
"pubkey": "nodeid020202020202020202020202020202020202020202020202020202020202",
"payload": "payload010101010101010101010101010"
},
{
"pubkey": "nodeid030303030303030303030303030303030303030303030303030303030303",
"payload": "payload020202020202020202020202020"
},
{
"pubkey": "nodeid040404040404040404040404040404040404040404040404040404040404",
"payload": "payload030303030303030303030303030"
}
],
"assocdata": "assocdata0010101010101010101010101010101010101010101010101010101",
"session_key": "4141414141414141414141414141414141414141414141414141414141414141"
}
}
Response:
{
"onion": "onion20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020",
"shared_secrets": [
"sharedsecret2020202020202020202020202020202020202020202020202020",
"sharedsecret2121212121212121212121212121212121212121212121212121",
"sharedsecret2222222222222222222222222222222222222222222222222222"
]
}
π that's the whole page bestie! go build something iconic with it. no cap, you ate. π β¨
and finally, the lil sign-off: this beauty ships with Core Lightning v26.06.9 π§ π β mwah, go forth and onion. periodt. π
π¦ 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