Skip to content

Backport #4682: report sending peer (prev_hop) in OnionMessageIntercepted#3

Merged
saidalaoui-sq merged 3 commits into
cequals:0.2.3_forkfrom
Synesso:bcoin-7796-onion-message-origin
Jul 1, 2026
Merged

Backport #4682: report sending peer (prev_hop) in OnionMessageIntercepted#3
saidalaoui-sq merged 3 commits into
cequals:0.2.3_forkfrom
Synesso:bcoin-7796-onion-message-origin

Conversation

@Synesso

@Synesso Synesso commented Jul 1, 2026

Copy link
Copy Markdown

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_fork base the routing node pins.

What

Cherry-picks the two commits of upstream lightningdevkit#4682 onto 0.2.3_fork, plus one small fork adaptation:

  • Intercept onion messages for unknown SCID hops (2e7cc44c) — introduces NextMessageHop and changes Event::OnionMessageIntercepted.peer_node_idnext_hop.
  • Report the sending peer in Event::OnionMessageIntercepted (1a0e5304) — adds prev_hop: Option<PublicKey> (the required change).
  • Adapt NextMessageHop serialization to 0.2.3 fork ser macros — upstream uses impl_ser_tlv_based_enum!, which doesn't exist on this base; swapped to the fork's equivalent impl_writeable_tlv_based_enum! (same tuple-variant syntax, self-consistent Readable/Writeable).

Resulting event shape

OnionMessageIntercepted {
    prev_hop: Option<PublicKey>,   // sender — BRN filters lit on this
    next_hop: NextMessageHop,      // was peer_node_id: PublicKey
    message: msgs::OnionMessage,
}

Testing

  • All LDK crates the routing node consumes compile: lightning, -background-processor, -net-tokio, -invoice, -liquidity, -rapid-gossip-sync.
  • Only merge conflict was in the lightning-tests crate (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 in cequals/lightning-node bumps bee3c3cb → this merge SHA; handler implementation is tracked in BCOIN-7796.

tnull and others added 3 commits July 1, 2026 14:47
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>
@Synesso Synesso marked this pull request as ready for review July 1, 2026 05:17
@saidalaoui-sq saidalaoui-sq merged commit bc37b7d into cequals:0.2.3_fork Jul 1, 2026
5 of 21 checks passed
@Synesso Synesso deleted the bcoin-7796-onion-message-origin branch July 1, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants