Skip to content

Commit 1a1d53a

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 d2242f6 commit 1a1d53a

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
@@ -531,6 +531,14 @@ where
531531
}
532532
}
533533

534+
pub(crate) fn peel_onion_message(
535+
&self, msg: &OnionMessage
536+
) -> Result<PeeledOnion<<<CMH>::Target as CustomOnionMessageHandler>::CustomMessage>, ()> {
537+
peel_onion_message(
538+
msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
539+
)
540+
}
541+
534542
fn handle_onion_message_response<T: OnionMessageContents>(
535543
&self, response: Option<T>, reply_path: Option<BlindedPath>, log_suffix: fmt::Arguments
536544
) {
@@ -624,9 +632,7 @@ where
624632
CMH::Target: CustomOnionMessageHandler,
625633
{
626634
fn handle_onion_message(&self, _peer_node_id: &PublicKey, msg: &OnionMessage) {
627-
match peel_onion_message(
628-
msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
629-
) {
635+
match self.peel_onion_message(msg) {
630636
Ok(PeeledOnion::Receive(message, path_id, reply_path)) => {
631637
log_trace!(self.logger,
632638
"Received an onion message with path_id {:02x?} and {} reply_path",

0 commit comments

Comments
 (0)