Skip to content

[epic]: Implement Onion Messaging (BOLT4) and Support Downstream BOLT12 Features #10220

Closed

Description

@gijswijs

Background

This issue tracks the implementation of Onion Messaging (BOLT4) in lnd and related changes needed for future BOLT12 features (e.g., offers, invoice requests, invoices and invoice errors). Onion Messaging provides a protocol for sending and receiving general-purpose onion-encrypted messages across the Lightning Network, independent of HTLC payments.

Stage 1 - Forwarding Onion Messaging

The first step towards adoption of onion messaging is relaying onion messages sent by others. The node will announce the feature bit that indicates the node can forward onion messages (38/39), and the message type for onion messages (513).

Stage 1 is divided over 5 PRs.

  • Basic structures for onion messages into LND #9868: The first pull request introduces the basic structures for onion messages into LND. It adds a new message type, OnionMessage, to the lnwire package. Additionally, it exposes functionality for handling these messages via new endpoints: SendOnionMessageand SubscribeOnionMessages.

  • lightning-onion Onion messaging support: This PR introduces support for onion messages in the lightning-onion package. This involves adding extensive tests using spec test vectors for creating, concatenating, and processing blinded onion routes. The code is updated to handle custom-sized onion packets, allowing for larger payloads typical of onion messages. Additionally, a change was made to correctly decode zero-length TLV payloads, which can occur in onion messages.

  • lightning-onion NoOp Replay Protection: This PR introduces support for running a router without replay protection. Replay protection isn't needed for onion messaging, so we can do without the memory/disk load.

  • Onion message forwarding #10089: This PR implements the core onion message forwarding logic. It defines the structure of the onion's inner payload and updates the htlcswitch to decrypt and process it. The OnionEndpoint is refactored to handle these payloads: if the node is not the final destination, it decrypts its layer and forwards the message to the next hop. Finally, RPCs and integration tests are updated to support this new forwarding capability. This PR also depends on both lightning-onion PRs and actor: add new package for structured concurrency based on the Actor model  #9820

  • Async handling of Onion Messages with BackpressureQueue #10219: This PR makes onion message handling asynchronous to improve performance. It introduces a new BackpressureQueue to manage high message volumes by randomly dropping messages when the queue is nearly full. Incoming onion messages are now added to this queue instead of being processed immediately, with a dedicated background goroutine handling decryption and forwarding. This prevents high traffic from blocking peer communication and enhances node stability. This PR also depends on queue: add new BackpressureQueue[T] variant #9838.

Stage 2 - Path Finding for Onion Messages

A dedicated pathfinding functionality for onion messages is a necessary precursor for implementing BOLT 12 features.

  • Graph-Based Pathfinding:

    • Implement a new pathfinding algorithm that searches the channel graph for a route to a destination node.
    • This search would filter for nodes that have advertised the OnionMessages feature bit, ensuring all hops can forward the message.
    • Unlike HTLC pathfinding, this search would focus only on connectivity and not on channel capacity or fees.
  • RPC and API Modification:

    • The existing SendOnionMessage RPC would be updated to take a final destination public key instead of just a direct peer.
    • Internally, this would trigger the new pathfinding logic to find a route to that destination.
  • Fallback to Direct Connection:

    • If the pathfinding logic fails to find a suitable multi-hop route, the system would implement the fallback behavior : attempt to establish a direct connection with the destination peer to deliver the message.

Stage 3 - Offer Creation and Invoice Request Handling

  • Implement the logic to create and store BOLT 12 offers.
  • Add the ability to construct blinded paths to the local node for inclusion in offers.
  • Expose this functionality via new RPC endpoints for creating and managing offers.
  • Develop the application logic to handle incoming onion messages that contain invoice_request payloads.
  • Validating the request against a stored offer, generating a corresponding BOLT 12 invoice, and sending it back using the onion message reply_path.

Activity

  1. self-assigned this
    on Sep 15, 2025
  2. added
    size/gigavery large, specialized context, over 10000 lines
    on Sep 15, 2025
  3. added theissue type on Sep 15, 2025
  4. added this to the v0.21.0 milestone on Sep 15, 2025
  5. moved this to In progress in v0.21on Sep 29, 2025
  6. Abdulkbk commented on Oct 2, 2025

    @Abdulkbk
    Contributor

    Thanks, @gijswijs, for creating this comprehensive tracker. I've been doing some research/learning on Onion Message (BOLT4) recently. I will keenly follow the progress of this project and hopefully contribute to it.

  7. gijswijs commented on Nov 3, 2025

    @gijswijs
    CollaboratorAuthor

    After #10219 we should follow up lightningnetwork/lightning-onion#68 with a PR that stops writing onion messages to the replay log. cc: @ziggie1984

  8. gijswijs commented on Jan 8, 2026

    @gijswijs
    CollaboratorAuthor

    NoOp Replay protection PR is up: lightningnetwork/lightning-onion#75
    cc: @saubyk

  9. gijswijs commented on Jan 13, 2026

    @gijswijs
    CollaboratorAuthor

    Mentioned #9820 in the epic which is a dependency that wasn't properly identified in the epic.

  10. Abdulkbk commented on Mar 12, 2026

    @Abdulkbk
    Contributor

    Worked on a pathfinding PR. I’d love to hear @gijswijs your thoughts on whether this is the right step in the right direction.

  11. moved this from In progress to In review in v0.21on Mar 25, 2026
  12. ziggie1984 commented on Mar 30, 2026

    @ziggie1984
    Collaborator

    Project milestones accomplished

  13. moved this from In review to Done in v0.21on Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bolt12brontideepicIssues created to track large feature developmentsize/gigavery large, specialized context, over 10000 lines

Projects

  • Status
    Done
  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions