Skip to content

Commit 57d9f22

Browse files
committed
Qualify the BOLT 11 invoice features type
A previous commit qualified the BOLT 11 invoice type, so any related types should be similarly qualified, if public.
1 parent 62ca48f commit 57d9f22

File tree

7 files changed

+77
-77
lines changed

7 files changed

+77
-77
lines changed

lightning-invoice/src/de.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use secp256k1::PublicKey;
2525

2626
use super::{Bolt11Invoice, Sha256, TaggedField, ExpiryTime, MinFinalCltvExpiryDelta, Fallback, PayeePubKey, InvoiceSignature, PositiveTimestamp,
2727
Bolt11SemanticError, PrivateRoute, Bolt11ParseError, ParseOrSemanticError, Description, RawTaggedField, Currency, RawHrp, SiPrefix, RawBolt11Invoice,
28-
constants, SignedRawBolt11Invoice, RawDataPart, InvoiceFeatures};
28+
constants, SignedRawBolt11Invoice, RawDataPart, Bolt11InvoiceFeatures};
2929

3030
use self::hrp_sm::parse_hrp;
3131

@@ -463,7 +463,7 @@ impl FromBase32 for TaggedField {
463463
constants::TAG_PAYMENT_METADATA =>
464464
Ok(TaggedField::PaymentMetadata(Vec::<u8>::from_base32(field_data)?)),
465465
constants::TAG_FEATURES =>
466-
Ok(TaggedField::Features(InvoiceFeatures::from_base32(field_data)?)),
466+
Ok(TaggedField::Features(Bolt11InvoiceFeatures::from_base32(field_data)?)),
467467
_ => {
468468
// "A reader MUST skip over unknown fields"
469469
Err(Bolt11ParseError::Skip)
@@ -969,14 +969,14 @@ mod test {
969969

970970
#[test]
971971
fn test_payment_secret_and_features_de_and_ser() {
972-
use lightning::ln::features::InvoiceFeatures;
972+
use lightning::ln::features::Bolt11InvoiceFeatures;
973973
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
974974
use crate::TaggedField::*;
975975
use crate::{SiPrefix, SignedRawBolt11Invoice, InvoiceSignature, RawBolt11Invoice, RawHrp, RawDataPart,
976976
Currency, Sha256, PositiveTimestamp};
977977

978978
// Feature bits 9, 15, and 99 are set.
979-
let expected_features = InvoiceFeatures::from_le_bytes(vec![0, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8]);
979+
let expected_features = Bolt11InvoiceFeatures::from_le_bytes(vec![0, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8]);
980980
let invoice_str = "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqpqsq67gye39hfg3zd8rgc80k32tvy9xk2xunwm5lzexnvpx6fd77en8qaq424dxgt56cag2dpt359k3ssyhetktkpqh24jqnjyw6uqd08sgptq44qu";
981981
let invoice = SignedRawBolt11Invoice {
982982
raw_invoice: RawBolt11Invoice {

lightning-invoice/src/lib.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use bitcoin::{Address, Network, PubkeyHash, ScriptHash};
5151
use bitcoin::util::address::{Payload, WitnessVersion};
5252
use bitcoin_hashes::{Hash, sha256};
5353
use lightning::ln::PaymentSecret;
54-
use lightning::ln::features::InvoiceFeatures;
54+
use lightning::ln::features::Bolt11InvoiceFeatures;
5555
#[cfg(any(doc, test))]
5656
use lightning::routing::gossip::RoutingFees;
5757
use lightning::routing::router::RouteHint;
@@ -448,7 +448,7 @@ pub enum TaggedField {
448448
PrivateRoute(PrivateRoute),
449449
PaymentSecret(PaymentSecret),
450450
PaymentMetadata(Vec<u8>),
451-
Features(InvoiceFeatures),
451+
Features(Bolt11InvoiceFeatures),
452452
}
453453

454454
/// SHA-256 hash
@@ -744,7 +744,7 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, M: tb::Bool> InvoiceBui
744744
}
745745
self.tagged_fields.push(TaggedField::PaymentSecret(payment_secret));
746746
if !found_features {
747-
let mut features = InvoiceFeatures::empty();
747+
let mut features = Bolt11InvoiceFeatures::empty();
748748
features.set_variable_length_onion_required();
749749
features.set_payment_secret_required();
750750
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
770770
}
771771
}
772772
if !found_features {
773-
let mut features = InvoiceFeatures::empty();
773+
let mut features = Bolt11InvoiceFeatures::empty();
774774
features.set_payment_metadata_optional();
775775
self.tagged_fields.push(TaggedField::Features(features));
776776
}
@@ -1059,7 +1059,7 @@ impl RawBolt11Invoice {
10591059
find_extract!(self.known_tagged_fields(), TaggedField::PaymentMetadata(ref x), x)
10601060
}
10611061

1062-
pub fn features(&self) -> Option<&InvoiceFeatures> {
1062+
pub fn features(&self) -> Option<&Bolt11InvoiceFeatures> {
10631063
find_extract!(self.known_tagged_fields(), TaggedField::Features(ref x), x)
10641064
}
10651065

@@ -1336,7 +1336,7 @@ impl Bolt11Invoice {
13361336
}
13371337

13381338
/// Get the invoice features if they were included in the invoice
1339-
pub fn features(&self) -> Option<&InvoiceFeatures> {
1339+
pub fn features(&self) -> Option<&Bolt11InvoiceFeatures> {
13401340
self.signed_invoice.features()
13411341
}
13421342

@@ -1863,7 +1863,7 @@ mod test {
18631863
#[test]
18641864
fn test_check_feature_bits() {
18651865
use crate::TaggedField::*;
1866-
use lightning::ln::features::InvoiceFeatures;
1866+
use lightning::ln::features::Bolt11InvoiceFeatures;
18671867
use secp256k1::Secp256k1;
18681868
use secp256k1::SecretKey;
18691869
use crate::{Bolt11Invoice, RawBolt11Invoice, RawHrp, RawDataPart, Currency, Sha256, PositiveTimestamp,
@@ -1904,12 +1904,12 @@ mod test {
19041904
let invoice = {
19051905
let mut invoice = invoice_template.clone();
19061906
invoice.data.tagged_fields.push(PaymentSecret(payment_secret).into());
1907-
invoice.data.tagged_fields.push(Features(InvoiceFeatures::empty()).into());
1907+
invoice.data.tagged_fields.push(Features(Bolt11InvoiceFeatures::empty()).into());
19081908
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
19091909
}.unwrap();
19101910
assert_eq!(Bolt11Invoice::from_signed(invoice), Err(Bolt11SemanticError::InvalidFeatures));
19111911

1912-
let mut payment_secret_features = InvoiceFeatures::empty();
1912+
let mut payment_secret_features = Bolt11InvoiceFeatures::empty();
19131913
payment_secret_features.set_payment_secret_required();
19141914

19151915
// Including payment secret and feature bits
@@ -1931,7 +1931,7 @@ mod test {
19311931
// No payment secret or feature bits
19321932
let invoice = {
19331933
let mut invoice = invoice_template.clone();
1934-
invoice.data.tagged_fields.push(Features(InvoiceFeatures::empty()).into());
1934+
invoice.data.tagged_fields.push(Features(Bolt11InvoiceFeatures::empty()).into());
19351935
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
19361936
}.unwrap();
19371937
assert_eq!(Bolt11Invoice::from_signed(invoice), Err(Bolt11SemanticError::NoPaymentSecret));
@@ -2147,7 +2147,7 @@ mod test {
21472147
assert_eq!(invoice.payment_hash(), &sha256::Hash::from_slice(&[21;32][..]).unwrap());
21482148
assert_eq!(invoice.payment_secret(), &PaymentSecret([42; 32]));
21492149

2150-
let mut expected_features = InvoiceFeatures::empty();
2150+
let mut expected_features = Bolt11InvoiceFeatures::empty();
21512151
expected_features.set_variable_length_onion_required();
21522152
expected_features.set_payment_secret_required();
21532153
expected_features.set_basic_mpp_optional();

lightning/src/ln/channelmanager.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use crate::ln::{inbound_payment, PaymentHash, PaymentPreimage, PaymentSecret};
4343
use crate::ln::channel::{Channel, ChannelContext, ChannelError, ChannelUpdateStatus, ShutdownResult, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel};
4444
use crate::ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
4545
#[cfg(any(feature = "_test_utils", test))]
46-
use crate::ln::features::InvoiceFeatures;
46+
use crate::ln::features::Bolt11InvoiceFeatures;
4747
use crate::routing::gossip::NetworkGraph;
4848
use crate::routing::router::{BlindedTail, DefaultRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
4949
use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters};
@@ -6928,13 +6928,13 @@ where
69286928
provided_node_features(&self.default_configuration)
69296929
}
69306930

6931-
/// Fetches the set of [`InvoiceFeatures`] flags which are provided by or required by
6931+
/// Fetches the set of [`Bolt11InvoiceFeatures`] flags which are provided by or required by
69326932
/// [`ChannelManager`].
69336933
///
69346934
/// Note that the invoice feature flags can vary depending on if the invoice is a "phantom invoice"
69356935
/// or not. Thus, this method is not public.
69366936
#[cfg(any(feature = "_test_utils", test))]
6937-
pub fn invoice_features(&self) -> InvoiceFeatures {
6937+
pub fn invoice_features(&self) -> Bolt11InvoiceFeatures {
69386938
provided_invoice_features(&self.default_configuration)
69396939
}
69406940

@@ -7366,13 +7366,13 @@ pub(crate) fn provided_node_features(config: &UserConfig) -> NodeFeatures {
73667366
provided_init_features(config).to_context()
73677367
}
73687368

7369-
/// Fetches the set of [`InvoiceFeatures`] flags which are provided by or required by
7369+
/// Fetches the set of [`Bolt11InvoiceFeatures`] flags which are provided by or required by
73707370
/// [`ChannelManager`].
73717371
///
73727372
/// Note that the invoice feature flags can vary depending on if the invoice is a "phantom invoice"
73737373
/// or not. Thus, this method is not public.
73747374
#[cfg(any(feature = "_test_utils", test))]
7375-
pub(crate) fn provided_invoice_features(config: &UserConfig) -> InvoiceFeatures {
7375+
pub(crate) fn provided_invoice_features(config: &UserConfig) -> Bolt11InvoiceFeatures {
73767376
provided_init_features(config).to_context()
73777377
}
73787378

0 commit comments

Comments
 (0)