Move Padding into blinded_path module for use in blinded payments
[rust-lightning] / lightning / src / onion_message / packet.rs
index 8a5628f164ca358dd8df1d7aec5e58730247c67e..8b677e7bb611ea307067493bc2252685e7632636 100644 (file)
@@ -12,7 +12,9 @@
 use bitcoin::secp256k1::PublicKey;
 use bitcoin::secp256k1::ecdh::SharedSecret;
 
-use crate::blinded_path::{BlindedPath, ForwardTlvs, ReceiveTlvs};
+use crate::blinded_path::BlindedPath;
+use crate::blinded_path::message::{ForwardTlvs, ReceiveTlvs};
+use crate::blinded_path::utils::Padding;
 use crate::ln::msgs::DecodeError;
 use crate::ln::onion_utils;
 use super::messenger::CustomOnionMessageHandler;
@@ -151,7 +153,8 @@ pub(super) enum ForwardControlTlvs {
        Blinded(Vec<u8>),
        /// If we're constructing an onion message hop through an intermediate unblinded node, we'll need
        /// to construct the intermediate hop's control TLVs in their unblinded state to avoid encoding
-       /// them into an intermediate Vec. See [`crate::blinded_path::ForwardTlvs`] for more info.
+       /// them into an intermediate Vec. See [`crate::blinded_path::message::ForwardTlvs`] for more
+       /// info.
        Unblinded(ForwardTlvs),
 }
 
@@ -159,7 +162,7 @@ pub(super) enum ForwardControlTlvs {
 pub(super) enum ReceiveControlTlvs {
        /// See [`ForwardControlTlvs::Blinded`].
        Blinded(Vec<u8>),
-       /// See [`ForwardControlTlvs::Unblinded`] and [`crate::blinded_path::ReceiveTlvs`].
+       /// See [`ForwardControlTlvs::Unblinded`] and [`crate::blinded_path::message::ReceiveTlvs`].
        Unblinded(ReceiveTlvs),
 }
 
@@ -304,16 +307,3 @@ impl Readable for ControlTlvs {
                Ok(payload_fmt)
        }
 }
-
-/// Reads padding to the end, ignoring what's read.
-pub(crate) struct Padding {}
-impl Readable for Padding {
-       #[inline]
-       fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
-               loop {
-                       let mut buf = [0; 8192];
-                       if reader.read(&mut buf[..])? == 0 { break; }
-               }
-               Ok(Self {})
-       }
-}