X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffeatures.rs;h=888dcd3ac0c076f36eb8058712f8c708d4827d42;hb=refs%2Fheads%2F2021-10-no-payment-id-leaks;hp=d1f6b89db4f87e968e3624289331c00c476875fe;hpb=35573bb3d7bf8c7f7b9d8759afa555aec2735a44;p=rust-lightning diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index d1f6b89d..888dcd3a 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -392,7 +392,6 @@ impl InitFeatures { /// Writes all features present up to, and including, 13. pub(crate) fn write_up_to_13(&self, w: &mut W) -> Result<(), io::Error> { let len = cmp::min(2, self.flags.len()); - w.size_hint(len + 2); (len as u16).write(w)?; for i in (0..len).rev() { if i == 0 { @@ -433,11 +432,11 @@ impl InvoiceFeatures { /// Getting a route for a keysend payment to a private node requires providing the payee's /// features (since they were not announced in a node announcement). However, keysend payments /// don't have an invoice to pull the payee's features from, so this method is provided for use in - /// [`get_keysend_route`], thus omitting the need for payers to manually construct an - /// `InvoiceFeatures` for [`get_route`]. + /// [`Payee::for_keysend`], thus omitting the need for payers to manually construct an + /// `InvoiceFeatures` for [`find_route`]. /// - /// [`get_keysend_route`]: crate::routing::router::get_keysend_route - /// [`get_route`]: crate::routing::router::get_route + /// [`Payee::for_keysend`]: crate::routing::router::Payee::for_keysend + /// [`find_route`]: crate::routing::router::find_route pub(crate) fn for_keysend() -> InvoiceFeatures { InvoiceFeatures::empty().set_variable_length_onion_optional() } @@ -584,12 +583,6 @@ impl Features { (byte & unknown_features) != 0 }) } - - /// The number of bytes required to represent the feature flags present. This does not include - /// the length bytes which are included in the serialized form. - pub(crate) fn byte_count(&self) -> usize { - self.flags.len() - } } impl Features { @@ -702,7 +695,6 @@ impl Features { impl Writeable for Features { fn write(&self, w: &mut W) -> Result<(), io::Error> { - w.size_hint(self.flags.len() + 2); (self.flags.len() as u16).write(w)?; for f in self.flags.iter().rev() { // Swap back to big-endian f.write(w)?; @@ -835,7 +827,7 @@ mod tests { #[test] fn convert_to_context_with_unknown_flags() { // Ensure the `from` context has fewer known feature bytes than the `to` context. - assert!(InvoiceFeatures::known().byte_count() < NodeFeatures::known().byte_count()); + assert!(InvoiceFeatures::known().flags.len() < NodeFeatures::known().flags.len()); let invoice_features = InvoiceFeatures::known().set_unknown_feature_optional(); assert!(invoice_features.supports_unknown_bits()); let node_features: NodeFeatures = invoice_features.to_context();