Onion Message
Layered-encryption messages passed between Lightning nodes outside of payments.
Basically
Onion messages let computers on the Lightning Network send encrypted data to each other. You do not need payment channels along the route, and no money moves.
Key Takeaways
- Onion messages extend Lightning's onion routing beyond payments. Nodes can send arbitrary encrypted data through the network without opening channels or locking funds in HTLCs.
- Onion messages are the transport layer for BOLT 12 offers. The invoice request and response flow that enables reusable, static payment codes relies entirely on onion messages for communication.
- Blinded reply paths protect sender privacy. The recipient never learns the sender's node identity, and intermediary nodes can only see the next hop in the route.
What Is an Onion Message?
An onion message is a one-way encrypted message routed through the Lightning Network. It uses the same layered encryption that protects payments. Unlike standard Lightning payments, it carries data rather than value: no HTLCs are created, no channels need to exist along the path, and no funds are locked at any point.
The protocol was formally specified in BOLT #4 (Onion Routing). It was merged into the Lightning specification in July 2023 via PR #759, and nodes signal support through feature bits 38/39 (option_onion_messages) in their node announcements and init messages.
Onion messages were introduced primarily to support BOLT 12 offers. Payers and merchants need a way to exchange invoice requests and invoices without relying on external servers. Before onion messages, Lightning lacked a native mechanism for nodes to communicate anything other than payment data.
How It Works
Onion messages use the same Sphinx packet construction as Lightning payments. Several key differences make them suitable for general-purpose messaging.
Message Structure
An onion message is sent as wire message type 513 (onion_message). Its structure includes the routing information and encrypted payloads used by each hop.
Differences from Payment Onions
Onion messages reuse Lightning's onion routing cryptography. Several structural differences set them apart from payment onions.
Per-Hop TLV Payloads
Each hop in the onion message decrypts its own TLV (type-length-value) payload. The key TLV fields include the forwarding and recipient data for that hop.
Intermediate nodes decrypt their encrypted_recipient_data using ECDH with the blinding point. The decrypted data reveals either a next_node_id or short_channel_id for forwarding. Each hop can only see the next destination, so it cannot determine the sender, recipient, or total path length.
Blinded Reply Paths
Onion messages are one-way, so the sender must include a blinded reply path if they expect a response. The blinded path structure routes back to the sender without revealing their identity.
The reply path contains the blinded routing data needed for the return journey. Its components keep the sender's actual node hidden.
The recipient only sees the entry node of the reply path, not the sender's actual node. Each hop in the blinded path can only decrypt its own forwarding instructions. The exchange can therefore be fully private, with neither side learning the other's node identity.
The final hop's encrypted data can include a path_id field. The field allows the sender to recognise which blinded path was used to reach them. That supports stateless path validation: the sender can publish multiple blinded paths and identify incoming replies without maintaining per-path state.
BOLT 12 Offer Flow
The primary use case for onion messages is the BOLT 12 offers protocol. Offers are static, reusable payment codes that replace single-use BOLT 11 invoices for many scenarios. The entire offer-to-payment flow runs over onion messages, from the invoice request to the returned invoice.
The flow eliminates the need for external HTTP servers, as required by LNURL with BOLT 11. The entire negotiation happens within the Lightning Network itself. For a deeper look at how this changes the payment experience, see the BOLT 12 offers deep dive.
Private Communication
Onion messages provide a general-purpose encrypted communication channel between Lightning nodes beyond payment negotiation. Potential applications include other coordination and data-exchange tasks that benefit from private routing.
Async Payment Coordination
Async payments send funds to offline recipients and require coordination messages between the sender, the recipient's LSP, and the recipient once they come online. Onion messages provide the private communication channel needed for this coordination. Payment details stay hidden from the network.
Why It Matters
Onion messages transform Lightning from a pure payment network into a private communication layer. Before their introduction, Lightning nodes could only exchange structured payment data or public gossip. Any communication beyond that required external infrastructure, such as HTTP servers, Tor hidden services, or other out-of-band channels.
Privacy matters here: BOLT 11 invoices require the recipient to run a web server via LNURL to handle invoice requests dynamically, exposing an IP address or requiring Tor configuration. BOLT 12 offers with onion messages eliminate this requirement entirely, making the Lightning Network itself the communication medium and using blinded paths to ensure neither party reveals their node identity. For more on how this improves Lightning privacy, see the blinded path privacy analysis.
Layer-2 protocols like Spark need private node communication channels to coordinate off-chain state. These channels avoid leaking information to the broader network.
Denial-of-Service Exposure
Forwarding onion messages costs resources, including bandwidth and CPU for decryption, but provides no economic incentive. Payment forwarding earns routing fees, while relaying an onion message generates no revenue for intermediate nodes. The result is a natural vector for spam and denial-of-service attacks.
The specification addresses this risk by allowing nodes to rate-limit messages by simply dropping them. Bastien Teinturier of ACINQ authored the proposed rate-limiting scheme. It suggests per-peer limits of approximately 10 messages per second from peers with an established channel and roughly 1 message per second from peers without one.
Backpressure Mechanism
A node that rate-limits onion messages can send an onion_message_drop (message type 515) back to the peer that forwarded the dropped message. The backpressure signal causes the sending peer to halve its rate limit for that connection, with limits gradually doubling after 30 seconds of compliance. The adaptive mechanism prevents sudden traffic spikes from overwhelming forwarding nodes.
Channel-Only Relay
Nodes can signal feature bits 66/67 (option_onion_messages_only_channels) to indicate they only accept onion messages from peers with an established channel. The requirement for channel funding creates an economic commitment before a peer can send messages, significantly reducing DoS exposure. LND, which added onion message support in v0.21, drops messages from non-channel peers by default.
No Delivery Guarantee
Onion messages offer no acknowledgement or delivery confirmation at the protocol level. A rate-limiting node can drop a message, or a hop can be offline, without giving the sender any way to know the message was lost. For BOLT 12 flows, the payer may need to retry invoice requests if no response arrives within a reasonable timeout.
Implementation Status
Onion message support varies across Lightning implementations. Support levels and default behaviour differ between them.
As adoption grows, onion messages will become the standard transport for all node-to-node communication beyond payments. For background on how onion routing protects privacy in Lightning, see the onion routing privacy research.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.