Skip to content

Commit 0daed42

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 122c965 commit 0daed42

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
@@ -199,11 +199,13 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
199199
utils::construct_blinded_hops(secp_ctx, pks, tlvs, session_priv)
200200
}
201201

202-
// Advance the blinded onion message path by one hop, so make the second hop into the new
203-
// introduction node.
204-
//
205-
// Will only modify `path` when returning `Ok`.
206-
pub(crate) fn advance_path_by_one<NS: Deref, NL: Deref, T>(
202+
/// Advance the blinded onion message path by one hop, so make the second hop into the new
203+
/// introduction node. Useful if we are sending an onion message to a [`BlindedPath`] where we are
204+
/// the introduction node, since the message should then be forwarded to the node after us in the
205+
/// path.
206+
///
207+
/// Will only modify `path` when returning `Ok`.
208+
pub fn advance_message_path_by_one<NS: Deref, NL: Deref, T>(
207209
path: &mut BlindedPath, node_signer: &NS, node_id_lookup: &NL, secp_ctx: &Secp256k1<T>
208210
) -> Result<(), ()>
209211
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, ReceiveTlvs};
19+
use crate::blinded_path::message::{advance_message_path_by_one, ForwardNode, ForwardTlvs, MessageContext, ReceiveTlvs};
2020
use crate::blinded_path::utils;
2121
use crate::events::{Event, EventHandler, EventsProvider, ReplayEvent};
2222
use crate::sign::{EntropySource, NodeSigner, Recipient};
@@ -874,7 +874,7 @@ where
874874
},
875875
};
876876
if introduction_node_id == our_node_id {
877-
advance_path_by_one(blinded_path, node_signer, node_id_lookup, &secp_ctx)
877+
advance_message_path_by_one(blinded_path, node_signer, node_id_lookup, &secp_ctx)
878878
.map_err(|()| SendError::BlindedPathAdvanceFailed)?;
879879
}
880880
}

0 commit comments

Comments
 (0)