Skip to content

Commit 58a0c13

Browse files
Add parsing logic for dummy hops
Adds support for identifying and handling dummy hops during the onion message peeling process. Ensures that Dummy Forward TLVs are correctly recognized and interpreted as non-routing hops. Co-authored-by: valentinewallace <[email protected]>
1 parent 463cc94 commit 58a0c13

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lightning/src/onion_message/messenger.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -1104,11 +1104,6 @@ where
11041104
})),
11051105
Some((next_hop_hmac, new_packet_bytes)),
11061106
)) => {
1107-
// TODO: we need to check whether `next_hop` is our node, in which case this is a dummy
1108-
// blinded hop and this onion message is destined for us. In this situation, we should keep
1109-
// unwrapping the onion layers to get to the final payload. Since we don't have the option
1110-
// of creating blinded paths with dummy hops currently, we should be ok to not handle this
1111-
// for now.
11121107
let packet_pubkey = msg.onion_routing_packet.public_key;
11131108
let new_pubkey_opt =
11141109
onion_utils::next_hop_pubkey(&secp_ctx, packet_pubkey, &onion_decode_ss);
@@ -1145,7 +1140,18 @@ where
11451140
onion_routing_packet: outgoing_packet,
11461141
};
11471142

1148-
Ok(PeeledOnion::Forward(next_hop, onion_message))
1143+
let our_node_id = node_signer.get_node_id(Recipient::Node).unwrap();
1144+
1145+
match next_hop {
1146+
NextMessageHop::NodeId(ref id) if id == &our_node_id => peel_onion_message(
1147+
&onion_message,
1148+
secp_ctx,
1149+
node_signer,
1150+
logger,
1151+
custom_handler,
1152+
),
1153+
_ => Ok(PeeledOnion::Forward(next_hop, onion_message)),
1154+
}
11491155
},
11501156
Err(e) => {
11511157
log_trace!(logger, "Errored decoding onion message packet: {:?}", e);

0 commit comments

Comments
 (0)