Skip to content

Commit 304577b

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 fad9dbd commit 304577b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,14 @@ where
795795
self.enqueue_onion_message(path, contents, reply_path, format_args!(""))
796796
}
797797

798+
pub(crate) fn peel_onion_message(
799+
&self, msg: &OnionMessage
800+
) -> Result<PeeledOnion<<<CMH>::Target as CustomOnionMessageHandler>::CustomMessage>, ()> {
801+
peel_onion_message(
802+
msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
803+
)
804+
}
805+
798806
fn handle_onion_message_response<T: OnionMessageContents>(
799807
&self, response: Option<T>, reply_path: Option<BlindedPath>, log_suffix: fmt::Arguments
800808
) {
@@ -880,9 +888,7 @@ where
880888
CMH::Target: CustomOnionMessageHandler,
881889
{
882890
fn handle_onion_message(&self, _peer_node_id: &PublicKey, msg: &OnionMessage) {
883-
match peel_onion_message(
884-
msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
885-
) {
891+
match self.peel_onion_message(msg) {
886892
Ok(PeeledOnion::Receive(message, path_id, reply_path)) => {
887893
log_trace!(
888894
self.logger,

0 commit comments

Comments
 (0)