Add logging in route hint filtering
[rust-lightning] / lightning / src / util / logger.rs
index ff576e26ddf4ca485d648c943ad3f36384b30653..546650da3bb75cb44f847e6e0e3f1b5015c4fd93 100644 (file)
@@ -14,6 +14,8 @@
 //! The second one, client-side by implementing check against Record Level field.
 //! Each module may have its own Logger or share one.
 
+use bitcoin::secp256k1::PublicKey;
+
 use core::cmp;
 use core::fmt;
 
@@ -138,6 +140,19 @@ pub trait Logger {
        fn log(&self, record: &Record);
 }
 
+/// Wrapper for logging a [`PublicKey`] in hex format.
+/// (C-not exported) as fmt can't be used in C
+#[doc(hidden)]
+pub struct DebugPubKey<'a>(pub &'a PublicKey);
+impl<'a> core::fmt::Display for DebugPubKey<'a> {
+       fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
+               for i in self.0.serialize().iter() {
+                       write!(f, "{:02x}", i)?;
+               }
+               Ok(())
+       }
+}
+
 /// Wrapper for logging byte slices in hex format.
 /// (C-not exported) as fmt can't be used in C
 #[doc(hidden)]