Skip to content

Commit ec8c6fb

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 ea5de93 commit ec8c6fb

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

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

0 commit comments

Comments
 (0)