]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Fix blinded hop feature serialization.
authorValentine Wallace <vwallace@protonmail.com>
Wed, 24 Jul 2024 18:09:10 +0000 (14:09 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Mon, 19 Aug 2024 16:47:42 +0000 (12:47 -0400)
We were writing a length redundantly...

lightning/src/blinded_path/payment.rs
lightning/src/ln/features.rs

index ca937c57d722f43c38a554509059b0f4771ad314..ffaff200e7b0e1897fb5ebe3e0f2e3b7f2fc0960 100644 (file)
@@ -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<W: Writer>(&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())),
                });
index 11e2b12dcdbf089b4ccf41002d8f19fe1b1e71bb..4637dfc2b250e9d0e43db2395915988155788a42 100644 (file)
@@ -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 {