Skip to content

Commit 05c7c61

Browse files
committed
Add peel_onion_message method to OnionMessenger
When testing OnionMessenger in functional tests, it would be useful to examine the contents of an OnionMessage response. Expose the standalone peel_onion_message on OnionMessenger to facilitate this.
1 parent 4deb263 commit 05c7c61

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lightning/src/onion_message/messenger.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,14 @@ where
807807
self.enqueue_onion_message(path, contents, reply_path, format_args!(""))
808808
}
809809

810+
pub(crate) fn peel_onion_message(
811+
&self, msg: &OnionMessage
812+
) -> Result<PeeledOnion<<<CMH>::Target as CustomOnionMessageHandler>::CustomMessage>, ()> {
813+
peel_onion_message(
814+
msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
815+
)
816+
}
817+
810818
fn handle_onion_message_response<T: OnionMessageContents>(
811819
&self, response: Option<T>, reply_path: Option<BlindedPath>, log_suffix: fmt::Arguments
812820
) {
@@ -892,9 +900,7 @@ where
892900
CMH::Target: CustomOnionMessageHandler,
893901
{
894902
fn handle_onion_message(&self, _peer_node_id: &PublicKey, msg: &OnionMessage) {
895-
match peel_onion_message(
896-
msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
897-
) {
903+
match self.peel_onion_message(msg) {
898904
Ok(PeeledOnion::Receive(message, path_id, reply_path)) => {
899905
log_trace!(
900906
self.logger,

0 commit comments

Comments
 (0)