+ fn respond_with_onion_message<T: CustomOnionMessageContents>(
+ &self, response: OnionMessageContents<T>, path_id: Option<[u8; 32]>,
+ reply_path: Option<BlindedPath>
+ ) {
+ let sender = match self.node_signer.get_node_id(Recipient::Node) {
+ Ok(node_id) => node_id,
+ Err(_) => {
+ log_warn!(
+ self.logger, "Unable to retrieve node id when responding to onion message with \
+ path_id {:02x?}", path_id
+ );
+ return;
+ }
+ };
+
+ let peers = self.pending_messages.lock().unwrap().keys().copied().collect();
+
+ let destination = match reply_path {
+ Some(reply_path) => Destination::BlindedPath(reply_path),
+ None => {
+ log_trace!(
+ self.logger, "Missing reply path when responding to onion message with path_id \
+ {:02x?}", path_id
+ );
+ return;
+ },
+ };
+
+ let path = match self.message_router.find_path(sender, peers, destination) {
+ Ok(path) => path,
+ Err(()) => {
+ log_trace!(
+ self.logger, "Failed to find path when responding to onion message with \
+ path_id {:02x?}", path_id
+ );
+ return;
+ },
+ };
+
+ log_trace!(self.logger, "Responding to onion message with path_id {:02x?}", path_id);
+
+ if let Err(e) = self.send_onion_message(path, response, None) {
+ log_trace!(
+ self.logger, "Failed responding to onion message with path_id {:02x?}: {:?}",
+ path_id, e
+ );
+ return;
+ }
+ }
+