Skip to content

Commit a006308

Browse files
Error on static invoice with unknown required features.
1 parent c58e667 commit a006308

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4292,8 +4292,9 @@ where
42924292
) -> Result<(), Bolt12PaymentError> {
42934293
let mut res = Ok(());
42944294
PersistenceNotifierGuard::optionally_notify(self, || {
4295+
let features = self.bolt12_invoice_features();
42954296
let outbound_pmts_res = self.pending_outbound_payments.static_invoice_received(
4296-
invoice, payment_id, &*self.entropy_source, &self.pending_events
4297+
invoice, payment_id, features, &*self.entropy_source, &self.pending_events
42974298
);
42984299
let payment_release_secret = match outbound_pmts_res {
42994300
Ok(secret) => secret,

lightning/src/ln/outbound_payment.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,8 @@ impl OutboundPayments {
918918

919919
#[cfg(async_payments)]
920920
pub(super) fn static_invoice_received<ES: Deref>(
921-
&self, invoice: &StaticInvoice, payment_id: PaymentId, entropy_source: ES,
921+
&self, invoice: &StaticInvoice, payment_id: PaymentId, features: Bolt12InvoiceFeatures,
922+
entropy_source: ES,
922923
pending_events: &Mutex<VecDeque<(events::Event, Option<EventCompletionAction>)>>
923924
) -> Result<[u8; 32], Bolt12PaymentError> where ES::Target: EntropySource {
924925
macro_rules! abandon_with_entry {
@@ -944,6 +945,10 @@ impl OutboundPayments {
944945
if !invoice.from_same_offer(invreq) {
945946
return Err(Bolt12PaymentError::UnexpectedInvoice)
946947
}
948+
if invoice.invoice_features().requires_unknown_bits_from(&features) {
949+
abandon_with_entry!(entry, PaymentFailureReason::UnknownRequiredFeatures);
950+
return Err(Bolt12PaymentError::UnknownRequiredFeatures)
951+
}
947952
let amount_msat = match InvoiceBuilder::<DerivedSigningPubkey>::amount_msats(&invreq) {
948953
Ok(amt) => amt,
949954
Err(_) => {

0 commit comments

Comments
 (0)