Skip to content

Commit 1f22d24

Browse files
Manually implement Debug for onion message packets.
Previously we derived Debug, but that caused a lot of unreadable encrypted bytes to be printed.
1 parent 62f719a commit 1f22d24

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning/src/onion_message/packet.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::util::logger::Logger;
2424
use crate::util::ser::{BigSize, FixedLengthReader, LengthRead, LengthReadable, LengthReadableArgs, Readable, ReadableArgs, Writeable, Writer};
2525

2626
use core::cmp;
27+
use core::fmt;
2728
use crate::io::{self, Read};
2829
use crate::prelude::*;
2930

@@ -33,7 +34,7 @@ pub(super) const SMALL_PACKET_HOP_DATA_LEN: usize = 1300;
3334
pub(super) const BIG_PACKET_HOP_DATA_LEN: usize = 32768;
3435

3536
/// Packet of hop data for next peer
36-
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
37+
#[derive(Clone, Hash, PartialEq, Eq)]
3738
pub struct Packet {
3839
/// Bolt 04 version number
3940
pub version: u8,
@@ -62,6 +63,12 @@ impl onion_utils::Packet for Packet {
6263
}
6364
}
6465

66+
impl fmt::Debug for Packet {
67+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
68+
f.write_fmt(format_args!("Onion message packet version {} with hmac {:?}", self.version, &self.hmac[..]))
69+
}
70+
}
71+
6572
impl Writeable for Packet {
6673
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
6774
self.version.write(w)?;

0 commit comments

Comments
 (0)