Skip to content

Commit 5ec13b1

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 15b7f66 commit 5ec13b1

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
@@ -813,6 +813,14 @@ where
813813
self.enqueue_onion_message(path, contents, reply_path, format_args!(""))
814814
}
815815

816+
pub(crate) fn peel_onion_message(
817+
&self, msg: &OnionMessage
818+
) -> Result<PeeledOnion<<<CMH>::Target as CustomOnionMessageHandler>::CustomMessage>, ()> {
819+
peel_onion_message(
820+
msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
821+
)
822+
}
823+
816824
fn handle_onion_message_response<T: OnionMessageContents>(
817825
&self, response: Option<T>, reply_path: Option<BlindedPath>, log_suffix: fmt::Arguments
818826
) {
@@ -898,9 +906,7 @@ where
898906
CMH::Target: CustomOnionMessageHandler,
899907
{
900908
fn handle_onion_message(&self, _peer_node_id: &PublicKey, msg: &OnionMessage) {
901-
match peel_onion_message(
902-
msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
903-
) {
909+
match self.peel_onion_message(msg) {
904910
Ok(PeeledOnion::Receive(message, path_id, reply_path)) => {
905911
log_trace!(
906912
self.logger,

0 commit comments

Comments
 (0)