]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Error on static invoice with unknown required features.
authorValentine Wallace <vwallace@protonmail.com>
Thu, 29 Aug 2024 19:00:08 +0000 (15:00 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Fri, 13 Sep 2024 14:40:06 +0000 (10:40 -0400)
lightning/src/ln/channelmanager.rs
lightning/src/ln/outbound_payment.rs

index 0fe7bef69cf83a52b9ffdb99cd39eb4ce6f68b70..dbd44ec0db73f89e75c65d0c724440c5c2e37a0a 100644 (file)
@@ -4326,8 +4326,9 @@ where
        ) -> Result<(), Bolt12PaymentError> {
                let mut res = Ok(());
                PersistenceNotifierGuard::optionally_notify(self, || {
+                       let features = self.bolt12_invoice_features();
                        let outbound_pmts_res = self.pending_outbound_payments.static_invoice_received(
-                               invoice, payment_id, &*self.entropy_source, &self.pending_events
+                               invoice, payment_id, features, &*self.entropy_source, &self.pending_events
                        );
                        let payment_release_secret = match outbound_pmts_res {
                                Ok(secret) => secret,
index db8ca6e909a24f19060f3350cf15234033272b78..f6ba4d9f859aebb71ae743c1670432d92212ae9f 100644 (file)
@@ -936,7 +936,8 @@ impl OutboundPayments {
 
        #[cfg(async_payments)]
        pub(super) fn static_invoice_received<ES: Deref>(
-               &self, invoice: &StaticInvoice, payment_id: PaymentId, entropy_source: ES,
+               &self, invoice: &StaticInvoice, payment_id: PaymentId, features: Bolt12InvoiceFeatures,
+               entropy_source: ES,
                pending_events: &Mutex<VecDeque<(events::Event, Option<EventCompletionAction>)>>
        ) -> Result<[u8; 32], Bolt12PaymentError> where ES::Target: EntropySource {
                macro_rules! abandon_with_entry {
@@ -967,6 +968,10 @@ impl OutboundPayments {
                                        if !invoice.from_same_offer(invreq) {
                                                return Err(Bolt12PaymentError::UnexpectedInvoice)
                                        }
+                                       if invoice.invoice_features().requires_unknown_bits_from(&features) {
+                                               abandon_with_entry!(entry, PaymentFailureReason::UnknownRequiredFeatures);
+                                               return Err(Bolt12PaymentError::UnknownRequiredFeatures)
+                                       }
                                        let amount_msat = match InvoiceBuilder::<DerivedSigningPubkey>::amount_msats(invreq) {
                                                Ok(amt) => amt,
                                                Err(_) => {