]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add peel_onion_message method to OnionMessenger
authorJeffrey Czyz <jkczyz@gmail.com>
Wed, 1 Nov 2023 18:12:44 +0000 (13:12 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Tue, 16 Jan 2024 02:12:36 +0000 (20:12 -0600)
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.

lightning/src/onion_message/messenger.rs

index 5dc3bb422e67efffc880465ad5ab3769ce48fc7a..812429f907d133b8ac67b7602e0cc9a8ba6e37f2 100644 (file)
@@ -814,6 +814,14 @@ where
                self.enqueue_onion_message(path, contents, reply_path, format_args!(""))
        }
 
+       pub(crate) fn peel_onion_message(
+               &self, msg: &OnionMessage
+       ) -> Result<PeeledOnion<<<CMH>::Target as CustomOnionMessageHandler>::CustomMessage>, ()> {
+               peel_onion_message(
+                       msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
+               )
+       }
+
        fn handle_onion_message_response<T: OnionMessageContents>(
                &self, response: Option<T>, reply_path: Option<BlindedPath>, log_suffix: fmt::Arguments
        ) {
@@ -899,9 +907,7 @@ where
        CMH::Target: CustomOnionMessageHandler,
 {
        fn handle_onion_message(&self, _peer_node_id: &PublicKey, msg: &OnionMessage) {
-               match peel_onion_message(
-                       msg, &self.secp_ctx, &*self.node_signer, &*self.logger, &*self.custom_handler
-               ) {
+               match self.peel_onion_message(msg) {
                        Ok(PeeledOnion::Receive(message, path_id, reply_path)) => {
                                log_trace!(
                                        self.logger,