X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fonion_message%2Fmessenger.rs;h=dbfa0bc636a3de78ac0cdf5f87ab6f31960583c8;hb=cff88aa5097ca09cfbd869eea9b24f61e6977b2f;hp=b50282433b18a128df1185711861a98ea0b44aa4;hpb=e691e5077dd4d770c948962af177d49819b51be3;p=rust-lightning diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index b5028243..dbfa0bc6 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -16,7 +16,7 @@ use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey}; use crate::blinded_path::{BlindedPath, ForwardTlvs, ReceiveTlvs, utils}; -use crate::chain::keysinterface::{EntropySource, KeysManager, NodeSigner, Recipient}; +use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient}; use crate::events::OnionMessageProvider; use crate::ln::features::{InitFeatures, NodeFeatures}; use crate::ln::msgs::{self, OnionMessageHandler}; @@ -43,7 +43,7 @@ use crate::prelude::*; /// # use bitcoin::hashes::_export::_core::time::Duration; /// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; /// # use lightning::blinded_path::BlindedPath; -/// # use lightning::chain::keysinterface::KeysManager; +/// # use lightning::sign::KeysManager; /// # use lightning::ln::peer_handler::IgnoringMessageHandler; /// # use lightning::onion_message::{CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger}; /// # use lightning::util::logger::{Logger, Record}; @@ -157,7 +157,7 @@ pub enum SendError { BufferFull, /// Failed to retrieve our node id from the provided [`NodeSigner`]. /// - /// [`NodeSigner`]: crate::chain::keysinterface::NodeSigner + /// [`NodeSigner`]: crate::sign::NodeSigner GetNodeIdFailed, /// We attempted to send to a blinded path where we are the introduction node, and failed to /// advance the blinded path to make the second hop the new introduction node. Either @@ -216,8 +216,8 @@ impl OnionMessenger return Err(SendError::TooFewBlindedHops); } } - let OnionMessageContents::Custom(ref msg) = message; - if msg.tlv_type() < 64 { return Err(SendError::InvalidMessage) } + + if message.tlv_type() < 64 { return Err(SendError::InvalidMessage) } // If we are sending straight to a blinded path and we are the introduction node, we need to // advance the blinded path by 1 hop so the second hop is the new introduction node. @@ -301,7 +301,7 @@ fn outbound_buffer_full(peer_node_id: &PublicKey, buffer: &HashMap OnionMessageHandler for OnionMessenger where ES::Target: EntropySource, NS::Target: NodeSigner, - L::Target: Logger, + L::Target: Logger + Sized, CMH::Target: CustomOnionMessageHandler + Sized, { /// Handle an incoming onion message. Currently, if a message was destined for us we will log, but @@ -331,9 +331,10 @@ impl OnionMessageHandler for OnionMe } } }; - match onion_utils::decode_next_untagged_hop(onion_decode_ss, &msg.onion_routing_packet.hop_data[..], - msg.onion_routing_packet.hmac, (control_tlvs_ss, &*self.custom_handler)) - { + match onion_utils::decode_next_untagged_hop( + onion_decode_ss, &msg.onion_routing_packet.hop_data[..], msg.onion_routing_packet.hmac, + (control_tlvs_ss, &*self.custom_handler, &*self.logger) + ) { Ok((Payload::Receive::<<::Target as CustomOnionMessageHandler>::CustomMessage> { message, control_tlvs: ReceiveControlTlvs::Unblinded(ReceiveTlvs { path_id }), reply_path, }, None)) => { @@ -341,6 +342,7 @@ impl OnionMessageHandler for OnionMe "Received an onion message with path_id {:02x?} and {} reply_path", path_id, if reply_path.is_some() { "a" } else { "no" }); match message { + OnionMessageContents::Offers(_msg) => todo!(), OnionMessageContents::Custom(msg) => self.custom_handler.handle_custom_message(msg), } }, @@ -567,6 +569,6 @@ fn construct_onion_message_packet(payloads: Vec<( BIG_PACKET_HOP_DATA_LEN } else { return Err(()) }; - Ok(onion_utils::construct_onion_message_packet::<_, _>( - payloads, onion_keys, prng_seed, hop_data_len)) + onion_utils::construct_onion_message_packet::<_, _>( + payloads, onion_keys, prng_seed, hop_data_len) }