X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fonion_message%2Fpacket.rs;h=75ec3cd90ab83c811b18b1283eab668ca7ddcb1d;hb=a8bd4c097f7ae6620eee66c1cb49144e38568439;hp=bbf04ca3ef4baa3f9e27562f073941e254a482d4;hpb=15d016ac520077b01604f2ede57be83d65e08e59;p=rust-lightning diff --git a/lightning/src/onion_message/packet.rs b/lightning/src/onion_message/packet.rs index bbf04ca3..75ec3cd9 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; @@ -24,6 +24,7 @@ use crate::util::logger::Logger; use crate::util::ser::{BigSize, FixedLengthReader, LengthRead, LengthReadable, LengthReadableArgs, Readable, ReadableArgs, Writeable, Writer}; use core::cmp; +use core::fmt; use crate::io::{self, Read}; use crate::prelude::*; @@ -33,7 +34,7 @@ pub(super) const SMALL_PACKET_HOP_DATA_LEN: usize = 1300; pub(super) const BIG_PACKET_HOP_DATA_LEN: usize = 32768; /// Packet of hop data for next peer -#[derive(Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Clone, Hash, PartialEq, Eq)] pub struct Packet { /// Bolt 04 version number pub version: u8, @@ -62,6 +63,12 @@ impl onion_utils::Packet for Packet { } } +impl fmt::Debug for Packet { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_fmt(format_args!("Onion message packet version {} with hmac {:?}", self.version, &self.hmac[..])) + } +} + impl Writeable for Packet { fn write(&self, w: &mut W) -> Result<(), io::Error> { self.version.write(w)?; @@ -117,7 +124,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), @@ -302,8 +309,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, };