From: Valentine Wallace Date: Wed, 24 Jul 2024 18:09:10 +0000 (-0400) Subject: Fix blinded hop feature serialization. X-Git-Tag: v0.0.124-beta~3^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=9dba36a4411edea9947504d10e339f1a166afe25;p=rust-lightning Fix blinded hop feature serialization. We were writing a length redundantly... --- diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs index ca937c57d..ffaff200e 100644 --- a/lightning/src/blinded_path/payment.rs +++ b/lightning/src/blinded_path/payment.rs @@ -26,7 +26,7 @@ use crate::offers::invoice_request::InvoiceRequestFields; use crate::offers::offer::OfferId; use crate::routing::gossip::{NodeId, ReadOnlyNetworkGraph}; use crate::sign::{EntropySource, NodeSigner, Recipient}; -use crate::util::ser::{FixedLengthReader, LengthReadableArgs, HighZeroBytesDroppedBigSize, Readable, Writeable, Writer}; +use crate::util::ser::{FixedLengthReader, LengthReadableArgs, HighZeroBytesDroppedBigSize, Readable, WithoutLength, Writeable, Writer}; use core::mem; use core::ops::Deref; @@ -344,7 +344,7 @@ impl Writeable for ForwardTlvs { fn write(&self, w: &mut W) -> Result<(), io::Error> { let features_opt = if self.features == BlindedHopFeatures::empty() { None } - else { Some(&self.features) }; + else { Some(WithoutLength(&self.features)) }; encode_tlv_stream!(w, { (2, self.short_channel_id, required), (10, self.payment_relay, required), @@ -385,7 +385,7 @@ impl Readable for BlindedPaymentTlvs { (8, next_blinding_override, option), (10, payment_relay, option), (12, payment_constraints, required), - (14, features, option), + (14, features, (option, encoding: (BlindedHopFeatures, WithoutLength))), (65536, payment_secret, option), (65537, payment_context, (default_value, PaymentContext::unknown())), }); diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 11e2b12dc..4637dfc2b 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -98,6 +98,7 @@ impl_feature_write_without_length!(Bolt12InvoiceFeatures); impl_feature_write_without_length!(ChannelTypeFeatures); impl_feature_write_without_length!(InvoiceRequestFeatures); impl_feature_write_without_length!(OfferFeatures); +impl_feature_write_without_length!(BlindedHopFeatures); #[cfg(test)] mod tests {