From e4d7681cba45da748c2863100ac036f84e96f343 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Thu, 29 Aug 2024 15:00:08 -0400 Subject: [PATCH] Error on static invoice with unknown required features. --- lightning/src/ln/channelmanager.rs | 3 ++- lightning/src/ln/outbound_payment.rs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 0fe7bef69..dbd44ec0d 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -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, diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs index db8ca6e90..f6ba4d9f8 100644 --- a/lightning/src/ln/outbound_payment.rs +++ b/lightning/src/ln/outbound_payment.rs @@ -936,7 +936,8 @@ impl OutboundPayments { #[cfg(async_payments)] pub(super) fn static_invoice_received( - &self, invoice: &StaticInvoice, payment_id: PaymentId, entropy_source: ES, + &self, invoice: &StaticInvoice, payment_id: PaymentId, features: Bolt12InvoiceFeatures, + entropy_source: ES, pending_events: &Mutex)>> ) -> 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::::amount_msats(invreq) { Ok(amt) => amt, Err(_) => { -- 2.39.5