X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fonion_message%2Fpacket.rs;h=32feb075b614201fb48bb4927d800d6704214605;hb=3fb329b004aa5107750ef87dfd2d1766badc705e;hp=510f0ea025a0d615b0f54292d865602ac7e103a6;hpb=ac9a2c8a20dadf5e68cbc3141072e73e20ca5004;p=rust-lightning diff --git a/lightning/src/onion_message/packet.rs b/lightning/src/onion_message/packet.rs index 510f0ea0..32feb075 100644 --- a/lightning/src/onion_message/packet.rs +++ b/lightning/src/onion_message/packet.rs @@ -12,8 +12,8 @@ use bitcoin::secp256k1::PublicKey; use bitcoin::secp256k1::ecdh::SharedSecret; -use crate::blinded_path::BlindedPath; -use crate::blinded_path::message::{ForwardTlvs, NextHop, ReceiveTlvs}; +use crate::blinded_path::{BlindedPath, NextMessageHop}; +use crate::blinded_path::message::{ForwardTlvs, ReceiveTlvs}; use crate::blinded_path::utils::Padding; use crate::ln::msgs::DecodeError; use crate::ln::onion_utils; @@ -117,7 +117,7 @@ pub(super) enum Payload { /// The contents of an [`OnionMessage`] as read from the wire. /// /// [`OnionMessage`]: crate::ln::msgs::OnionMessage -#[derive(Debug)] +#[derive(Clone, Debug)] pub enum ParsedOnionMessageContents { /// A message related to BOLT 12 Offers. Offers(OffersMessage), @@ -135,6 +135,12 @@ impl OnionMessageContents for ParsedOnionMessageContent &ParsedOnionMessageContents::Custom(ref msg) => msg.tlv_type(), } } + fn msg_type(&self) -> &'static str { + match self { + ParsedOnionMessageContents::Offers(ref msg) => msg.msg_type(), + ParsedOnionMessageContents::Custom(ref msg) => msg.msg_type(), + } + } } impl Writeable for ParsedOnionMessageContents { @@ -150,6 +156,9 @@ impl Writeable for ParsedOnionMessageContents { pub trait OnionMessageContents: Writeable + core::fmt::Debug { /// Returns the TLV type identifying the message contents. MUST be >= 64. fn tlv_type(&self) -> u64; + + /// Returns the message type + fn msg_type(&self) -> &'static str; } /// Forward control TLVs in their blinded and unblinded form. @@ -293,8 +302,8 @@ impl Readable for ControlTlvs { let next_hop = match (short_channel_id, next_node_id) { (Some(_), Some(_)) => return Err(DecodeError::InvalidValue), - (Some(scid), None) => Some(NextHop::ShortChannelId(scid)), - (None, Some(pubkey)) => Some(NextHop::NodeId(pubkey)), + (Some(scid), None) => Some(NextMessageHop::ShortChannelId(scid)), + (None, Some(pubkey)) => Some(NextMessageHop::NodeId(pubkey)), (None, None) => None, };