Skip to content

Commit e4d7681

Browse files
Error on static invoice with unknown required features.
1 parent 28269a7 commit e4d7681

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
@@ -4326,8 +4326,9 @@ where
43264326
) -> Result<(), Bolt12PaymentError> {
43274327
let mut res = Ok(());
43284328
PersistenceNotifierGuard::optionally_notify(self, || {
4329+
let features = self.bolt12_invoice_features();
43294330
let outbound_pmts_res = self.pending_outbound_payments.static_invoice_received(
4330-
invoice, payment_id, &*self.entropy_source, &self.pending_events
4331+
invoice, payment_id, features, &*self.entropy_source, &self.pending_events
43314332
);
43324333
let payment_release_secret = match outbound_pmts_res {
43334334
Ok(secret) => secret,

lightning/src/ln/outbound_payment.rs

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

937937
#[cfg(async_payments)]
938938
pub(super) fn static_invoice_received<ES: Deref>(
939-
&self, invoice: &StaticInvoice, payment_id: PaymentId, entropy_source: ES,
939+
&self, invoice: &StaticInvoice, payment_id: PaymentId, features: Bolt12InvoiceFeatures,
940+
entropy_source: ES,
940941
pending_events: &Mutex<VecDeque<(events::Event, Option<EventCompletionAction>)>>
941942
) -> Result<[u8; 32], Bolt12PaymentError> where ES::Target: EntropySource {
942943
macro_rules! abandon_with_entry {
@@ -967,6 +968,10 @@ impl OutboundPayments {
967968
if !invoice.from_same_offer(invreq) {
968969
return Err(Bolt12PaymentError::UnexpectedInvoice)
969970
}
971+
if invoice.invoice_features().requires_unknown_bits_from(&features) {
972+
abandon_with_entry!(entry, PaymentFailureReason::UnknownRequiredFeatures);
973+
return Err(Bolt12PaymentError::UnknownRequiredFeatures)
974+
}
970975
let amount_msat = match InvoiceBuilder::<DerivedSigningPubkey>::amount_msats(invreq) {
971976
Ok(amt) => amt,
972977
Err(_) => {

0 commit comments

Comments
 (0)