Backport #4682: report sending peer (prev_hop) in OnionMessageIntercepted#3
Merged
saidalaoui-sq merged 3 commits intoJul 1, 2026
Conversation
Allow integrations to intercept blinded onion-message hops that identify the next node by short channel id, so LSPS-style protocols can resolve those hops out of band instead of dropping the message. Co-Authored-By: HAL 9000
When the OnionMessenger intercepts an onion message to forward, it now reports which peer sent us the message via a new `prev_hop` field, so handlers can apply source-based policy when deciding whether to forward. `prev_hop` is `None` when the forward is enqueued by a message handler (the BOLT 12 static-invoice-server flow), which isn't given the sending node; otherwise it is the node we received the message from. Co-Authored-By: Claude <noreply@anthropic.com>
The upstream lightningdevkit#4682 commits use impl_ser_tlv_based_enum!, which does not exist on the 0.2.3_fork base. Use the fork's equivalent impl_writeable_tlv_based_enum!, which supports the same tuple-variant syntax and produces a self-consistent Readable/Writeable impl. Amp-Thread-ID: https://ampcode.com/threads/T-019f1bf1-a8e4-745c-8492-3d1c9ff270a0 Co-authored-by: Amp <amp@ampcode.com>
saidalaoui-sq
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Unblocks BCOIN-7796. To forward BOLT 12 onion messages to offline peers, the routing node (BRN) must filter intercepted messages by sender so it only forwards lit-originated traffic. That source info was added upstream in lightningdevkit/rust-lightning#4682, which is not in any released LDK version (unreleased 0.3-dev). This is the lowest-footprint way to get it onto the
0.2.3_forkbase the routing node pins.What
Cherry-picks the two commits of upstream lightningdevkit#4682 onto
0.2.3_fork, plus one small fork adaptation:2e7cc44c) — introducesNextMessageHopand changesEvent::OnionMessageIntercepted.peer_node_id→next_hop.Event::OnionMessageIntercepted(1a0e5304) — addsprev_hop: Option<PublicKey>(the required change).NextMessageHopserialization to 0.2.3 fork ser macros — upstream usesimpl_ser_tlv_based_enum!, which doesn't exist on this base; swapped to the fork's equivalentimpl_writeable_tlv_based_enum!(same tuple-variant syntax, self-consistent Readable/Writeable).Resulting event shape
Testing
lightning,-background-processor,-net-tokio,-invoice,-liquidity,-rapid-gossip-sync.lightning-testscrate (not consumed by the routing node); resolved by keeping the fork's version, which does not reference the changed event.Follow-up
Once merged, the workspace
[patch.crates-io]pin incequals/lightning-nodebumpsbee3c3cb→ this merge SHA; handler implementation is tracked in BCOIN-7796.