]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Only write BlindedHopFeatures if any features are set.
authorValentine Wallace <vwallace@protonmail.com>
Tue, 19 Mar 2024 18:58:43 +0000 (14:58 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Tue, 19 Mar 2024 18:58:43 +0000 (14:58 -0400)
Minor space-saving optimization.

lightning/src/blinded_path/payment.rs

index 0ed09a366d8be7075415b92abad585a51fad6c9b..6467af568886bd1891a7e8c52ae6b5956736f6bd 100644 (file)
@@ -120,11 +120,14 @@ impl TryFrom<CounterpartyForwardingInfo> for PaymentRelay {
 
 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) };
                encode_tlv_stream!(w, {
                        (2, self.short_channel_id, required),
                        (10, self.payment_relay, required),
                        (12, self.payment_constraints, required),
-                       (14, self.features, required)
+                       (14, features_opt, option)
                });
                Ok(())
        }