diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs index 5d332a76faf..7f938d6617f 100644 --- a/lightning/src/blinded_path/payment.rs +++ b/lightning/src/blinded_path/payment.rs @@ -13,7 +13,7 @@ use crate::ln::features::BlindedHopFeatures; use crate::ln::msgs::DecodeError; use crate::offers::invoice::BlindedPayInfo; use crate::prelude::*; -use crate::util::ser::{Readable, Writeable, Writer}; +use crate::util::ser::{HighZeroBytesDroppedBigSize, Readable, Writeable, Writer}; use core::convert::TryFrom; @@ -275,16 +275,35 @@ pub(super) fn compute_payinfo( }) } -impl_writeable_msg!(PaymentRelay, { - cltv_expiry_delta, - fee_proportional_millionths, - fee_base_msat -}, {}); +impl Writeable for PaymentRelay { + fn write(&self, w: &mut W) -> Result<(), io::Error> { + self.cltv_expiry_delta.write(w)?; + self.fee_proportional_millionths.write(w)?; + HighZeroBytesDroppedBigSize(self.fee_base_msat).write(w) + } +} +impl Readable for PaymentRelay { + fn read(r: &mut R) -> Result { + let cltv_expiry_delta: u16 = Readable::read(r)?; + let fee_proportional_millionths: u32 = Readable::read(r)?; + let fee_base_msat: HighZeroBytesDroppedBigSize = Readable::read(r)?; + Ok(Self { cltv_expiry_delta, fee_proportional_millionths, fee_base_msat: fee_base_msat.0 }) + } +} -impl_writeable_msg!(PaymentConstraints, { - max_cltv_expiry, - htlc_minimum_msat -}, {}); +impl Writeable for PaymentConstraints { + fn write(&self, w: &mut W) -> Result<(), io::Error> { + self.max_cltv_expiry.write(w)?; + HighZeroBytesDroppedBigSize(self.htlc_minimum_msat).write(w) + } +} +impl Readable for PaymentConstraints { + fn read(r: &mut R) -> Result { + let max_cltv_expiry: u32 = Readable::read(r)?; + let htlc_minimum_msat: HighZeroBytesDroppedBigSize = Readable::read(r)?; + Ok(Self { max_cltv_expiry, htlc_minimum_msat: htlc_minimum_msat.0 }) + } +} #[cfg(test)] mod tests { diff --git a/pending_changelog/relay-constraints-ser.txt b/pending_changelog/relay-constraints-ser.txt new file mode 100644 index 00000000000..f0da509b929 --- /dev/null +++ b/pending_changelog/relay-constraints-ser.txt @@ -0,0 +1,7 @@ +## Bug fixes + +* LDK previously serialized `PaymentRelay::fee_base_msat` as a u32 when it + should have been serialized as a tu32. Similarly, we were serializing + `PaymentConstraints::htlc_minimum_msat` as a u64 when we should have been + serializing it as tu64. This caused lack of interoperability when using other + implementations as forwarding nodes along blinded payment paths.