Skip to content

Commit 565e456

Browse files
committed
Resolve blinded path when creating onion message
Add a version of the create_onion_message utility function that attempts to resolved the introduction node of the destination's BlindedPath using a ReadOnlyNetworkGraph`. Otherwise, if given a path using the compact representation, using create_onion_message would fail. Keep the current version for use internally and for external uses where the blinded path is known to be resolved.
1 parent 5178585 commit 565e456

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lightning/src/onion_message/messenger.rs

+25
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,31 @@ pub enum PeeledOnion<T: OnionMessageContents> {
577577
Receive(ParsedOnionMessageContents<T>, Option<[u8; 32]>, Option<BlindedPath>)
578578
}
579579

580+
581+
/// Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
582+
/// `path`, first calling [`Destination::resolve`] on `path.destination` with the given
583+
/// [`ReadOnlyNetworkGraph`].
584+
///
585+
/// Returns the node id of the peer to send the message to, the message itself, and any addresses
586+
/// need to connect to the first node.
587+
pub fn create_onion_message_resolving_deestination<
588+
ES: Deref, NS: Deref, NL: Deref, T: OnionMessageContents
589+
>(
590+
entropy_source: &ES, node_signer: &NS, node_id_lookup: &NL,
591+
network_graph: &ReadOnlyNetworkGraph, secp_ctx: &Secp256k1<secp256k1::All>,
592+
mut path: OnionMessagePath, contents: T, reply_path: Option<BlindedPath>,
593+
) -> Result<(PublicKey, OnionMessage, Option<Vec<SocketAddress>>), SendError>
594+
where
595+
ES::Target: EntropySource,
596+
NS::Target: NodeSigner,
597+
NL::Target: NodeIdLookUp,
598+
{
599+
path.destination.resolve(network_graph);
600+
create_onion_message(
601+
entropy_source, node_signer, node_id_lookup, secp_ctx, path, contents, reply_path,
602+
)
603+
}
604+
580605
/// Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
581606
/// `path`.
582607
///

0 commit comments

Comments
 (0)