]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Qualify the BOLT 11 invoice features type
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 14 Jul 2023 19:41:58 +0000 (14:41 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 14 Jul 2023 20:49:00 +0000 (15:49 -0500)
A previous commit qualified the BOLT 11 invoice type, so any related
types should be similarly qualified, if public.

lightning-invoice/src/de.rs
lightning-invoice/src/lib.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/features.rs
lightning/src/ln/onion_route_tests.rs
lightning/src/ln/payment_tests.rs
lightning/src/routing/router.rs

index 3f0548efb751799ecfbad44c0edf133dbe0dc571..a62adaec1aa4992b764b1d3385b0b5dd2769e720 100644 (file)
@@ -25,7 +25,7 @@ use secp256k1::PublicKey;
 
 use super::{Bolt11Invoice, Sha256, TaggedField, ExpiryTime, MinFinalCltvExpiryDelta, Fallback, PayeePubKey, InvoiceSignature, PositiveTimestamp,
        Bolt11SemanticError, PrivateRoute, Bolt11ParseError, ParseOrSemanticError, Description, RawTaggedField, Currency, RawHrp, SiPrefix, RawBolt11Invoice,
-       constants, SignedRawBolt11Invoice, RawDataPart, InvoiceFeatures};
+       constants, SignedRawBolt11Invoice, RawDataPart, Bolt11InvoiceFeatures};
 
 use self::hrp_sm::parse_hrp;
 
@@ -463,7 +463,7 @@ impl FromBase32 for TaggedField {
                        constants::TAG_PAYMENT_METADATA =>
                                Ok(TaggedField::PaymentMetadata(Vec::<u8>::from_base32(field_data)?)),
                        constants::TAG_FEATURES =>
-                               Ok(TaggedField::Features(InvoiceFeatures::from_base32(field_data)?)),
+                               Ok(TaggedField::Features(Bolt11InvoiceFeatures::from_base32(field_data)?)),
                        _ => {
                                // "A reader MUST skip over unknown fields"
                                Err(Bolt11ParseError::Skip)
@@ -969,14 +969,14 @@ mod test {
 
        #[test]
        fn test_payment_secret_and_features_de_and_ser() {
-               use lightning::ln::features::InvoiceFeatures;
+               use lightning::ln::features::Bolt11InvoiceFeatures;
                use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
                use crate::TaggedField::*;
                use crate::{SiPrefix, SignedRawBolt11Invoice, InvoiceSignature, RawBolt11Invoice, RawHrp, RawDataPart,
                                 Currency, Sha256, PositiveTimestamp};
 
                // Feature bits 9, 15, and 99 are set.
-               let expected_features = InvoiceFeatures::from_le_bytes(vec![0, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8]);
+               let expected_features = Bolt11InvoiceFeatures::from_le_bytes(vec![0, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8]);
                let invoice_str = "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqpqsq67gye39hfg3zd8rgc80k32tvy9xk2xunwm5lzexnvpx6fd77en8qaq424dxgt56cag2dpt359k3ssyhetktkpqh24jqnjyw6uqd08sgptq44qu";
                let invoice = SignedRawBolt11Invoice {
                                        raw_invoice: RawBolt11Invoice {
index 21db4960417461e023110f41259deec6f189ff62..ee65f2fd6df8a952eb3dfa3f882b34e29e1b887f 100644 (file)
@@ -51,7 +51,7 @@ use bitcoin::{Address, Network, PubkeyHash, ScriptHash};
 use bitcoin::util::address::{Payload, WitnessVersion};
 use bitcoin_hashes::{Hash, sha256};
 use lightning::ln::PaymentSecret;
-use lightning::ln::features::InvoiceFeatures;
+use lightning::ln::features::Bolt11InvoiceFeatures;
 #[cfg(any(doc, test))]
 use lightning::routing::gossip::RoutingFees;
 use lightning::routing::router::RouteHint;
@@ -448,7 +448,7 @@ pub enum TaggedField {
        PrivateRoute(PrivateRoute),
        PaymentSecret(PaymentSecret),
        PaymentMetadata(Vec<u8>),
-       Features(InvoiceFeatures),
+       Features(Bolt11InvoiceFeatures),
 }
 
 /// SHA-256 hash
@@ -744,7 +744,7 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, M: tb::Bool> InvoiceBui
                }
                self.tagged_fields.push(TaggedField::PaymentSecret(payment_secret));
                if !found_features {
-                       let mut features = InvoiceFeatures::empty();
+                       let mut features = Bolt11InvoiceFeatures::empty();
                        features.set_variable_length_onion_required();
                        features.set_payment_secret_required();
                        self.tagged_fields.push(TaggedField::Features(features));
@@ -770,7 +770,7 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool> InvoiceBui
                        }
                }
                if !found_features {
-                       let mut features = InvoiceFeatures::empty();
+                       let mut features = Bolt11InvoiceFeatures::empty();
                        features.set_payment_metadata_optional();
                        self.tagged_fields.push(TaggedField::Features(features));
                }
@@ -1059,7 +1059,7 @@ impl RawBolt11Invoice {
                find_extract!(self.known_tagged_fields(), TaggedField::PaymentMetadata(ref x), x)
        }
 
-       pub fn features(&self) -> Option<&InvoiceFeatures> {
+       pub fn features(&self) -> Option<&Bolt11InvoiceFeatures> {
                find_extract!(self.known_tagged_fields(), TaggedField::Features(ref x), x)
        }
 
@@ -1336,7 +1336,7 @@ impl Bolt11Invoice {
        }
 
        /// Get the invoice features if they were included in the invoice
-       pub fn features(&self) -> Option<&InvoiceFeatures> {
+       pub fn features(&self) -> Option<&Bolt11InvoiceFeatures> {
                self.signed_invoice.features()
        }
 
@@ -1863,7 +1863,7 @@ mod test {
        #[test]
        fn test_check_feature_bits() {
                use crate::TaggedField::*;
-               use lightning::ln::features::InvoiceFeatures;
+               use lightning::ln::features::Bolt11InvoiceFeatures;
                use secp256k1::Secp256k1;
                use secp256k1::SecretKey;
                use crate::{Bolt11Invoice, RawBolt11Invoice, RawHrp, RawDataPart, Currency, Sha256, PositiveTimestamp, 
@@ -1904,12 +1904,12 @@ mod test {
                let invoice = {
                        let mut invoice = invoice_template.clone();
                        invoice.data.tagged_fields.push(PaymentSecret(payment_secret).into());
-                       invoice.data.tagged_fields.push(Features(InvoiceFeatures::empty()).into());
+                       invoice.data.tagged_fields.push(Features(Bolt11InvoiceFeatures::empty()).into());
                        invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
                }.unwrap();
                assert_eq!(Bolt11Invoice::from_signed(invoice), Err(Bolt11SemanticError::InvalidFeatures));
 
-               let mut payment_secret_features = InvoiceFeatures::empty();
+               let mut payment_secret_features = Bolt11InvoiceFeatures::empty();
                payment_secret_features.set_payment_secret_required();
 
                // Including payment secret and feature bits
@@ -1931,7 +1931,7 @@ mod test {
                // No payment secret or feature bits
                let invoice = {
                        let mut invoice = invoice_template.clone();
-                       invoice.data.tagged_fields.push(Features(InvoiceFeatures::empty()).into());
+                       invoice.data.tagged_fields.push(Features(Bolt11InvoiceFeatures::empty()).into());
                        invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
                }.unwrap();
                assert_eq!(Bolt11Invoice::from_signed(invoice), Err(Bolt11SemanticError::NoPaymentSecret));
@@ -2147,7 +2147,7 @@ mod test {
                assert_eq!(invoice.payment_hash(), &sha256::Hash::from_slice(&[21;32][..]).unwrap());
                assert_eq!(invoice.payment_secret(), &PaymentSecret([42; 32]));
 
-               let mut expected_features = InvoiceFeatures::empty();
+               let mut expected_features = Bolt11InvoiceFeatures::empty();
                expected_features.set_variable_length_onion_required();
                expected_features.set_payment_secret_required();
                expected_features.set_basic_mpp_optional();
index 07bb18ff37c346df4d4fdfe14e5d929556feb72e..a03a444e25d78c4aa0b89f37673e5c0bdb883cab 100644 (file)
@@ -43,7 +43,7 @@ use crate::ln::{inbound_payment, PaymentHash, PaymentPreimage, PaymentSecret};
 use crate::ln::channel::{Channel, ChannelContext, ChannelError, ChannelUpdateStatus, ShutdownResult, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel};
 use crate::ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
 #[cfg(any(feature = "_test_utils", test))]
-use crate::ln::features::InvoiceFeatures;
+use crate::ln::features::Bolt11InvoiceFeatures;
 use crate::routing::gossip::NetworkGraph;
 use crate::routing::router::{BlindedTail, DefaultRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
 use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters};
@@ -6928,13 +6928,13 @@ where
                provided_node_features(&self.default_configuration)
        }
 
-       /// Fetches the set of [`InvoiceFeatures`] flags which are provided by or required by
+       /// Fetches the set of [`Bolt11InvoiceFeatures`] flags which are provided by or required by
        /// [`ChannelManager`].
        ///
        /// Note that the invoice feature flags can vary depending on if the invoice is a "phantom invoice"
        /// or not. Thus, this method is not public.
        #[cfg(any(feature = "_test_utils", test))]
-       pub fn invoice_features(&self) -> InvoiceFeatures {
+       pub fn invoice_features(&self) -> Bolt11InvoiceFeatures {
                provided_invoice_features(&self.default_configuration)
        }
 
@@ -7366,13 +7366,13 @@ pub(crate) fn provided_node_features(config: &UserConfig) -> NodeFeatures {
        provided_init_features(config).to_context()
 }
 
-/// Fetches the set of [`InvoiceFeatures`] flags which are provided by or required by
+/// Fetches the set of [`Bolt11InvoiceFeatures`] flags which are provided by or required by
 /// [`ChannelManager`].
 ///
 /// Note that the invoice feature flags can vary depending on if the invoice is a "phantom invoice"
 /// or not. Thus, this method is not public.
 #[cfg(any(feature = "_test_utils", test))]
-pub(crate) fn provided_invoice_features(config: &UserConfig) -> InvoiceFeatures {
+pub(crate) fn provided_invoice_features(config: &UserConfig) -> Bolt11InvoiceFeatures {
        provided_init_features(config).to_context()
 }
 
index ca6ea70b61da7312de22b1e28749a51cb3f28941..6309eea413adb4d913c45379baad6eca16bdeb83 100644 (file)
@@ -168,7 +168,7 @@ mod sealed {
                ZeroConf | Keysend,
        ]);
        define_context!(ChannelContext, []);
-       define_context!(InvoiceContext, [
+       define_context!(Bolt11InvoiceContext, [
                // Byte 0
                ,
                // Byte 1
@@ -369,17 +369,17 @@ mod sealed {
        define_feature!(7, GossipQueries, [InitContext, NodeContext],
                "Feature flags for `gossip_queries`.", set_gossip_queries_optional, set_gossip_queries_required,
                supports_gossip_queries, requires_gossip_queries);
-       define_feature!(9, VariableLengthOnion, [InitContext, NodeContext, InvoiceContext],
+       define_feature!(9, VariableLengthOnion, [InitContext, NodeContext, Bolt11InvoiceContext],
                "Feature flags for `var_onion_optin`.", set_variable_length_onion_optional,
                set_variable_length_onion_required, supports_variable_length_onion,
                requires_variable_length_onion);
        define_feature!(13, StaticRemoteKey, [InitContext, NodeContext, ChannelTypeContext],
                "Feature flags for `option_static_remotekey`.", set_static_remote_key_optional,
                set_static_remote_key_required, supports_static_remote_key, requires_static_remote_key);
-       define_feature!(15, PaymentSecret, [InitContext, NodeContext, InvoiceContext],
+       define_feature!(15, PaymentSecret, [InitContext, NodeContext, Bolt11InvoiceContext],
                "Feature flags for `payment_secret`.", set_payment_secret_optional, set_payment_secret_required,
                supports_payment_secret, requires_payment_secret);
-       define_feature!(17, BasicMPP, [InitContext, NodeContext, InvoiceContext, Bolt12InvoiceContext],
+       define_feature!(17, BasicMPP, [InitContext, NodeContext, Bolt11InvoiceContext, Bolt12InvoiceContext],
                "Feature flags for `basic_mpp`.", set_basic_mpp_optional, set_basic_mpp_required,
                supports_basic_mpp, requires_basic_mpp);
        define_feature!(19, Wumbo, [InitContext, NodeContext],
@@ -403,7 +403,7 @@ mod sealed {
        define_feature!(47, SCIDPrivacy, [InitContext, NodeContext, ChannelTypeContext],
                "Feature flags for only forwarding with SCID aliasing. Called `option_scid_alias` in the BOLTs",
                set_scid_privacy_optional, set_scid_privacy_required, supports_scid_privacy, requires_scid_privacy);
-       define_feature!(49, PaymentMetadata, [InvoiceContext],
+       define_feature!(49, PaymentMetadata, [Bolt11InvoiceContext],
                "Feature flags for payment metadata in invoices.", set_payment_metadata_optional,
                set_payment_metadata_required, supports_payment_metadata, requires_payment_metadata);
        define_feature!(51, ZeroConf, [InitContext, NodeContext, ChannelTypeContext],
@@ -416,7 +416,7 @@ mod sealed {
 
        #[cfg(test)]
        define_feature!(123456789, UnknownFeature,
-               [NodeContext, ChannelContext, InvoiceContext, OfferContext, InvoiceRequestContext, Bolt12InvoiceContext, BlindedHopContext],
+               [NodeContext, ChannelContext, Bolt11InvoiceContext, OfferContext, InvoiceRequestContext, Bolt12InvoiceContext, BlindedHopContext],
                "Feature flags for an unknown feature used in testing.", set_unknown_feature_optional,
                set_unknown_feature_required, supports_unknown_test_feature, requires_unknown_test_feature);
 }
@@ -492,7 +492,7 @@ pub type NodeFeatures = Features<sealed::NodeContext>;
 /// Features used within a `channel_announcement` message.
 pub type ChannelFeatures = Features<sealed::ChannelContext>;
 /// Features used within an invoice.
-pub type InvoiceFeatures = Features<sealed::InvoiceContext>;
+pub type Bolt11InvoiceFeatures = Features<sealed::Bolt11InvoiceContext>;
 /// Features used within an `offer`.
 pub type OfferFeatures = Features<sealed::OfferContext>;
 /// Features used within an `invoice_request`.
@@ -538,8 +538,8 @@ impl InitFeatures {
        }
 }
 
-impl InvoiceFeatures {
-       /// Converts `InvoiceFeatures` to `Features<C>`. Only known `InvoiceFeatures` relevant to
+impl Bolt11InvoiceFeatures {
+       /// Converts `Bolt11InvoiceFeatures` to `Features<C>`. Only known `Bolt11InvoiceFeatures` relevant to
        /// context `C` are included in the result.
        pub(crate) fn to_context<C: sealed::Context>(&self) -> Features<C> {
                self.to_context_internal()
@@ -549,15 +549,15 @@ impl InvoiceFeatures {
        /// 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
        /// [`PaymentParameters::for_keysend`], thus omitting the need for payers to manually construct an
-       /// `InvoiceFeatures` for [`find_route`].
+       /// `Bolt11InvoiceFeatures` for [`find_route`].
        ///
        /// MPP keysend is not widely supported yet, so we parameterize support to allow the user to
        /// choose whether their router should find multi-part routes.
        ///
        /// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
        /// [`find_route`]: crate::routing::router::find_route
-       pub(crate) fn for_keysend(allow_mpp: bool) -> InvoiceFeatures {
-               let mut res = InvoiceFeatures::empty();
+       pub(crate) fn for_keysend(allow_mpp: bool) -> Bolt11InvoiceFeatures {
+               let mut res = Bolt11InvoiceFeatures::empty();
                res.set_variable_length_onion_optional();
                if allow_mpp {
                        res.set_basic_mpp_optional();
@@ -567,8 +567,8 @@ impl InvoiceFeatures {
 }
 
 impl Bolt12InvoiceFeatures {
-       /// Converts `Bolt12InvoiceFeatures` to `Features<C>`. Only known `Bolt12InvoiceFeatures` relevant
-       /// to context `C` are included in the result.
+       /// Converts [`Bolt12InvoiceFeatures`] to [`Features<C>`]. Only known [`Bolt12InvoiceFeatures`]
+       /// relevant to context `C` are included in the result.
        pub(crate) fn to_context<C: sealed::Context>(&self) -> Features<C> {
                self.to_context_internal()
        }
@@ -604,7 +604,7 @@ impl ChannelTypeFeatures {
        }
 }
 
-impl ToBase32 for InvoiceFeatures {
+impl ToBase32 for Bolt11InvoiceFeatures {
        fn write_base32<W: WriteBase32>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err> {
                // Explanation for the "4": the normal way to round up when dividing is to add the divisor
                // minus one before dividing
@@ -634,16 +634,16 @@ impl ToBase32 for InvoiceFeatures {
        }
 }
 
-impl Base32Len for InvoiceFeatures {
+impl Base32Len for Bolt11InvoiceFeatures {
        fn base32_len(&self) -> usize {
                self.to_base32().len()
        }
 }
 
-impl FromBase32 for InvoiceFeatures {
+impl FromBase32 for Bolt11InvoiceFeatures {
        type Err = bech32::Error;
 
-       fn from_base32(field_data: &[u5]) -> Result<InvoiceFeatures, bech32::Error> {
+       fn from_base32(field_data: &[u5]) -> Result<Bolt11InvoiceFeatures, bech32::Error> {
                // Explanation for the "7": the normal way to round up when dividing is to add the divisor
                // minus one before dividing
                let length_bytes = (field_data.len() * 5 + 7) / 8 as usize;
@@ -662,7 +662,7 @@ impl FromBase32 for InvoiceFeatures {
                while !res_bytes.is_empty() && res_bytes[res_bytes.len() - 1] == 0 {
                        res_bytes.pop();
                }
-               Ok(InvoiceFeatures::from_le_bytes(res_bytes))
+               Ok(Bolt11InvoiceFeatures::from_le_bytes(res_bytes))
        }
 }
 
@@ -903,7 +903,7 @@ macro_rules! impl_feature_len_prefixed_write {
 impl_feature_len_prefixed_write!(InitFeatures);
 impl_feature_len_prefixed_write!(ChannelFeatures);
 impl_feature_len_prefixed_write!(NodeFeatures);
-impl_feature_len_prefixed_write!(InvoiceFeatures);
+impl_feature_len_prefixed_write!(Bolt11InvoiceFeatures);
 impl_feature_len_prefixed_write!(Bolt12InvoiceFeatures);
 impl_feature_len_prefixed_write!(BlindedHopFeatures);
 
@@ -943,7 +943,7 @@ impl<T: sealed::Context> Readable for WithoutLength<Features<T>> {
 
 #[cfg(test)]
 mod tests {
-       use super::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, InvoiceFeatures, NodeFeatures, OfferFeatures, sealed};
+       use super::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, Bolt11InvoiceFeatures, NodeFeatures, OfferFeatures, sealed};
        use bitcoin::bech32::{Base32Len, FromBase32, ToBase32, u5};
        use crate::util::ser::{Readable, WithoutLength, Writeable};
 
@@ -1058,17 +1058,17 @@ mod tests {
        fn convert_to_context_with_unknown_flags() {
                // Ensure the `from` context has fewer known feature bytes than the `to` context.
                assert!(<sealed::ChannelContext as sealed::Context>::KNOWN_FEATURE_MASK.len() <
-                       <sealed::InvoiceContext as sealed::Context>::KNOWN_FEATURE_MASK.len());
+                       <sealed::Bolt11InvoiceContext as sealed::Context>::KNOWN_FEATURE_MASK.len());
                let mut channel_features = ChannelFeatures::empty();
                channel_features.set_unknown_feature_optional();
                assert!(channel_features.supports_unknown_bits());
-               let invoice_features: InvoiceFeatures = channel_features.to_context_internal();
+               let invoice_features: Bolt11InvoiceFeatures = channel_features.to_context_internal();
                assert!(!invoice_features.supports_unknown_bits());
        }
 
        #[test]
        fn set_feature_bits() {
-               let mut features = InvoiceFeatures::empty();
+               let mut features = Bolt11InvoiceFeatures::empty();
                features.set_basic_mpp_optional();
                features.set_payment_secret_required();
                assert!(features.supports_basic_mpp());
@@ -1079,7 +1079,7 @@ mod tests {
 
        #[test]
        fn set_custom_bits() {
-               let mut features = InvoiceFeatures::empty();
+               let mut features = Bolt11InvoiceFeatures::empty();
                features.set_variable_length_onion_optional();
                assert_eq!(features.flags[1], 0b00000010);
 
@@ -1089,19 +1089,19 @@ mod tests {
                assert_eq!(features.flags[31], 0b00000000);
                assert_eq!(features.flags[32], 0b00000101);
 
-               let known_bit = <sealed::InvoiceContext as sealed::PaymentSecret>::EVEN_BIT;
-               let byte_offset = <sealed::InvoiceContext as sealed::PaymentSecret>::BYTE_OFFSET;
+               let known_bit = <sealed::Bolt11InvoiceContext as sealed::PaymentSecret>::EVEN_BIT;
+               let byte_offset = <sealed::Bolt11InvoiceContext as sealed::PaymentSecret>::BYTE_OFFSET;
                assert_eq!(byte_offset, 1);
                assert_eq!(features.flags[byte_offset], 0b00000010);
                assert!(features.set_required_custom_bit(known_bit).is_err());
                assert_eq!(features.flags[byte_offset], 0b00000010);
 
-               let mut features = InvoiceFeatures::empty();
+               let mut features = Bolt11InvoiceFeatures::empty();
                assert!(features.set_optional_custom_bit(256).is_ok());
                assert!(features.set_optional_custom_bit(259).is_ok());
                assert_eq!(features.flags[32], 0b00001010);
 
-               let mut features = InvoiceFeatures::empty();
+               let mut features = Bolt11InvoiceFeatures::empty();
                assert!(features.set_required_custom_bit(257).is_ok());
                assert!(features.set_required_custom_bit(258).is_ok());
                assert_eq!(features.flags[32], 0b00000101);
@@ -1138,7 +1138,7 @@ mod tests {
                        u5::try_from_u8(16).unwrap(),
                        u5::try_from_u8(1).unwrap(),
                ];
-               let features = InvoiceFeatures::from_le_bytes(vec![1, 2, 3, 4, 5, 42, 100, 101]);
+               let features = Bolt11InvoiceFeatures::from_le_bytes(vec![1, 2, 3, 4, 5, 42, 100, 101]);
 
                // Test length calculation.
                assert_eq!(features.base32_len(), 13);
@@ -1148,13 +1148,13 @@ mod tests {
                assert_eq!(features_as_u5s, features_serialized);
 
                // Test deserialization.
-               let features_deserialized = InvoiceFeatures::from_base32(&features_as_u5s).unwrap();
+               let features_deserialized = Bolt11InvoiceFeatures::from_base32(&features_as_u5s).unwrap();
                assert_eq!(features, features_deserialized);
        }
 
        #[test]
        fn test_channel_type_mapping() {
-               // If we map an InvoiceFeatures with StaticRemoteKey optional, it should map into a
+               // If we map an Bolt11InvoiceFeatures with StaticRemoteKey optional, it should map into a
                // required-StaticRemoteKey ChannelTypeFeatures.
                let mut init_features = InitFeatures::empty();
                init_features.set_static_remote_key_optional();
index e5faedfe7fc39c958cc52f1c40fbcbc09bcebf27..1230d48ba1ed6d37df3a7f73f1737dc5b873c733 100644 (file)
@@ -20,7 +20,7 @@ use crate::ln::channelmanager::{HTLCForwardInfo, FailureCode, CLTV_FAR_FAR_AWAY,
 use crate::ln::onion_utils;
 use crate::routing::gossip::{NetworkUpdate, RoutingFees};
 use crate::routing::router::{get_route, PaymentParameters, Route, RouteHint, RouteHintHop};
-use crate::ln::features::{InitFeatures, InvoiceFeatures};
+use crate::ln::features::{InitFeatures, Bolt11InvoiceFeatures};
 use crate::ln::msgs;
 use crate::ln::msgs::{ChannelMessageHandler, ChannelUpdate};
 use crate::ln::wire::Encode;
@@ -862,7 +862,7 @@ fn test_always_create_tlv_format_onion_payloads() {
        create_announced_chan_between_nodes(&nodes, 1, 2);
 
        let payment_params = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id(), TEST_FINAL_CLTV)
-               .with_bolt11_features(InvoiceFeatures::empty()).unwrap();
+               .with_bolt11_features(Bolt11InvoiceFeatures::empty()).unwrap();
        let (route, _payment_hash, _payment_preimage, _payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], payment_params, 40000);
 
        let hops = &route.paths[0].hops;
index fa607f680981f3d68d81229834ad1becb6ed8b66..b23b6364182da0f8445f1da0f108dddfbf8ad86c 100644 (file)
@@ -18,7 +18,7 @@ use crate::chain::transaction::OutPoint;
 use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentFailureReason};
 use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
 use crate::ln::channelmanager::{BREAKDOWN_TIMEOUT, ChannelManager, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure, IDEMPOTENCY_TIMEOUT_TICKS, RecentPaymentDetails, RecipientOnionFields, HTLCForwardInfo, PendingHTLCRouting, PendingAddHTLCInfo};
-use crate::ln::features::InvoiceFeatures;
+use crate::ln::features::Bolt11InvoiceFeatures;
 use crate::ln::{msgs, PaymentSecret, PaymentPreimage};
 use crate::ln::msgs::ChannelMessageHandler;
 use crate::ln::outbound_payment::Retry;
@@ -1903,7 +1903,7 @@ fn do_automatic_retries(test: AutoRetry) {
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
        let amt_msat = 1000;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
@@ -2122,7 +2122,7 @@ fn auto_retry_partial_failure() {
        let payment_expiry_secs = SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() + 60 * 60;
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
@@ -2334,7 +2334,7 @@ fn auto_retry_zero_attempts_send_error() {
        let payment_expiry_secs = SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() + 60 * 60;
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
@@ -2374,7 +2374,7 @@ fn fails_paying_after_rejected_by_payee() {
        let payment_expiry_secs = SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() + 60 * 60;
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
@@ -2421,7 +2421,7 @@ fn retry_multi_path_single_failed_payment() {
        let payment_expiry_secs = SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() + 60 * 60;
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
@@ -2514,7 +2514,7 @@ fn immediate_retry_on_failure() {
        let payment_expiry_secs = SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() + 60 * 60;
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
@@ -2602,7 +2602,7 @@ fn no_extra_retries_on_back_to_back_fail() {
        let payment_expiry_secs = SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() + 60 * 60;
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
@@ -2804,7 +2804,7 @@ fn test_simple_partial_retry() {
        let payment_expiry_secs = SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() + 60 * 60;
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
@@ -2970,7 +2970,7 @@ fn test_threaded_payment_retries() {
        let payment_expiry_secs = SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() + 60 * 60;
        #[cfg(not(feature = "std"))]
        let payment_expiry_secs = 60 * 60;
-       let mut invoice_features = InvoiceFeatures::empty();
+       let mut invoice_features = Bolt11InvoiceFeatures::empty();
        invoice_features.set_variable_length_onion_required();
        invoice_features.set_payment_secret_required();
        invoice_features.set_basic_mpp_optional();
index 141e7d26cc13499685b2e28a671686acb1a73cf6..9242e98b1ab5061eca462e31b479f3e34602a8e3 100644 (file)
@@ -16,7 +16,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
 use crate::blinded_path::{BlindedHop, BlindedPath};
 use crate::ln::PaymentHash;
 use crate::ln::channelmanager::{ChannelDetails, PaymentId};
-use crate::ln::features::{Bolt12InvoiceFeatures, ChannelFeatures, InvoiceFeatures, NodeFeatures};
+use crate::ln::features::{Bolt11InvoiceFeatures, Bolt12InvoiceFeatures, ChannelFeatures, NodeFeatures};
 use crate::ln::msgs::{DecodeError, ErrorAction, LightningError, MAX_VALUE_MSAT};
 use crate::offers::invoice::{BlindedPayInfo, Bolt12Invoice};
 use crate::routing::gossip::{DirectedChannelInfo, EffectiveCapacity, ReadOnlyNetworkGraph, NetworkGraph, NodeId, RoutingFees};
@@ -640,7 +640,7 @@ impl PaymentParameters {
        /// [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only
        pub fn for_keysend(payee_pubkey: PublicKey, final_cltv_expiry_delta: u32, allow_mpp: bool) -> Self {
                Self::from_node_id(payee_pubkey, final_cltv_expiry_delta)
-                       .with_bolt11_features(InvoiceFeatures::for_keysend(allow_mpp))
+                       .with_bolt11_features(Bolt11InvoiceFeatures::for_keysend(allow_mpp))
                        .expect("PaymentParameters::from_node_id should always initialize the payee as unblinded")
        }
 
@@ -680,7 +680,7 @@ impl PaymentParameters {
        /// [`PaymentParameters::from_bolt12_invoice`].
        ///
        /// This is not exported to bindings users since bindings don't support move semantics
-       pub fn with_bolt11_features(self, features: InvoiceFeatures) -> Result<Self, ()> {
+       pub fn with_bolt11_features(self, features: Bolt11InvoiceFeatures) -> Result<Self, ()> {
                match self.payee {
                        Payee::Blinded { .. } => Err(()),
                        Payee::Clear { route_hints, node_id, final_cltv_expiry_delta, .. } =>
@@ -766,7 +766,7 @@ pub enum Payee {
                /// does not contain any features.
                ///
                /// [`for_keysend`]: PaymentParameters::for_keysend
-               features: Option<InvoiceFeatures>,
+               features: Option<Bolt11InvoiceFeatures>,
                /// The minimum CLTV delta at the end of the route. This value must not be zero.
                final_cltv_expiry_delta: u32,
        },
@@ -819,11 +819,11 @@ impl Payee {
 }
 
 enum FeaturesRef<'a> {
-       Bolt11(&'a InvoiceFeatures),
+       Bolt11(&'a Bolt11InvoiceFeatures),
        Bolt12(&'a Bolt12InvoiceFeatures),
 }
 enum Features {
-       Bolt11(InvoiceFeatures),
+       Bolt11(Bolt11InvoiceFeatures),
        Bolt12(Bolt12InvoiceFeatures),
 }
 
@@ -834,7 +834,7 @@ impl Features {
                        _ => None,
                }
        }
-       fn bolt11(self) -> Option<InvoiceFeatures> {
+       fn bolt11(self) -> Option<Bolt11InvoiceFeatures> {
                match self {
                        Self::Bolt11(f) => Some(f),
                        _ => None,
@@ -6104,7 +6104,7 @@ mod tests {
 
                let params = ProbabilisticScoringFeeParameters::default();
                let mut scorer = ProbabilisticScorer::new(ProbabilisticScoringDecayParameters::default(), &graph, &logger);
-               let features = super::InvoiceFeatures::empty();
+               let features = super::Bolt11InvoiceFeatures::empty();
 
                super::bench_utils::generate_test_routes(&graph, &mut scorer, &params, features, random_init_seed(), 0, 2);
        }
@@ -6680,7 +6680,7 @@ pub(crate) mod bench_utils {
        use crate::chain::transaction::OutPoint;
        use crate::sign::{EntropySource, KeysManager};
        use crate::ln::channelmanager::{self, ChannelCounterparty, ChannelDetails};
-       use crate::ln::features::InvoiceFeatures;
+       use crate::ln::features::Bolt11InvoiceFeatures;
        use crate::routing::gossip::NetworkGraph;
        use crate::util::config::UserConfig;
        use crate::util::ser::ReadableArgs;
@@ -6772,7 +6772,7 @@ pub(crate) mod bench_utils {
        }
 
        pub(crate) fn generate_test_routes<S: Score>(graph: &NetworkGraph<&TestLogger>, scorer: &mut S,
-               score_params: &S::ScoreParams, features: InvoiceFeatures, mut seed: u64,
+               score_params: &S::ScoreParams, features: Bolt11InvoiceFeatures, mut seed: u64,
                starting_amount: u64, route_count: usize,
        ) -> Vec<(ChannelDetails, PaymentParameters, u64)> {
                let payer = payer_pubkey();
@@ -6853,7 +6853,7 @@ pub mod benches {
        use super::*;
        use crate::sign::{EntropySource, KeysManager};
        use crate::ln::channelmanager;
-       use crate::ln::features::InvoiceFeatures;
+       use crate::ln::features::Bolt11InvoiceFeatures;
        use crate::routing::gossip::NetworkGraph;
        use crate::routing::scoring::{FixedPenaltyScorer, ProbabilisticScorer, ProbabilisticScoringFeeParameters, ProbabilisticScoringDecayParameters};
        use crate::util::config::UserConfig;
@@ -6871,7 +6871,7 @@ pub mod benches {
                let logger = TestLogger::new();
                let network_graph = bench_utils::read_network_graph(&logger).unwrap();
                let scorer = FixedPenaltyScorer::with_penalty(0);
-               generate_routes(bench, &network_graph, scorer, &(), InvoiceFeatures::empty(), 0,
+               generate_routes(bench, &network_graph, scorer, &(), Bolt11InvoiceFeatures::empty(), 0,
                        "generate_routes_with_zero_penalty_scorer");
        }
 
@@ -6889,7 +6889,7 @@ pub mod benches {
                let network_graph = bench_utils::read_network_graph(&logger).unwrap();
                let params = ProbabilisticScoringFeeParameters::default();
                let scorer = ProbabilisticScorer::new(ProbabilisticScoringDecayParameters::default(), &network_graph, &logger);
-               generate_routes(bench, &network_graph, scorer, &params, InvoiceFeatures::empty(), 0,
+               generate_routes(bench, &network_graph, scorer, &params, Bolt11InvoiceFeatures::empty(), 0,
                        "generate_routes_with_probabilistic_scorer");
        }
 
@@ -6915,7 +6915,7 @@ pub mod benches {
 
        fn generate_routes<S: Score>(
                bench: &mut Criterion, graph: &NetworkGraph<&TestLogger>, mut scorer: S,
-               score_params: &S::ScoreParams, features: InvoiceFeatures, starting_amount: u64,
+               score_params: &S::ScoreParams, features: Bolt11InvoiceFeatures, starting_amount: u64,
                bench_name: &'static str,
        ) {
                let payer = bench_utils::payer_pubkey();