Skip to content

Commit 92e38f0

Browse files
Expose blinded message paths' advance_path_by_one.
Useful for LDK users that are only using the onion messages module, like LNDK.
1 parent 53a2b55 commit 92e38f0

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,13 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
151151
utils::construct_blinded_hops(secp_ctx, pks, tlvs, session_priv)
152152
}
153153

154-
// Advance the blinded onion message path by one hop, so make the second hop into the new
155-
// introduction node.
156-
//
157-
// Will only modify `path` when returning `Ok`.
158-
pub(crate) fn advance_path_by_one<NS: Deref, NL: Deref, T>(
154+
/// Advance the blinded onion message path by one hop, so make the second hop into the new
155+
/// introduction node. Useful if we are sending an onion message to a [`BlindedPath`] where we are
156+
/// the introduction node, since the message should then be forwarded to the node after us in the
157+
/// path.
158+
///
159+
/// Will only modify `path` when returning `Ok`.
160+
pub fn advance_message_path_by_one<NS: Deref, NL: Deref, T>(
159161
path: &mut BlindedPath, node_signer: &NS, node_id_lookup: &NL, secp_ctx: &Secp256k1<T>
160162
) -> Result<(), ()>
161163
where

lightning/src/onion_message/messenger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
1616
use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey};
1717

1818
use crate::blinded_path::{BlindedPath, IntroductionNode, NextMessageHop, NodeIdLookUp};
19-
use crate::blinded_path::message::{advance_path_by_one, ForwardNode, ForwardTlvs, MessageContext, OffersContext, ReceiveTlvs};
19+
use crate::blinded_path::message::{advance_message_path_by_one, ForwardNode, ForwardTlvs, MessageContext, OffersContext, ReceiveTlvs};
2020
use crate::blinded_path::utils;
2121
use crate::events::{Event, EventHandler, EventsProvider};
2222
use crate::sign::{EntropySource, NodeSigner, Recipient};
@@ -875,7 +875,7 @@ where
875875
},
876876
};
877877
if introduction_node_id == our_node_id {
878-
advance_path_by_one(blinded_path, node_signer, node_id_lookup, &secp_ctx)
878+
advance_message_path_by_one(blinded_path, node_signer, node_id_lookup, &secp_ctx)
879879
.map_err(|()| SendError::BlindedPathAdvanceFailed)?;
880880
}
881881
}

0 commit comments

Comments
 (0)