Skip to content

Commit 33b6162

Browse files
committed
Remove InvoiceRequestFields::features
InvoiceRequestFeatures may contain a large, odd bit. Including this in InvoiceRequestFields, which is in each BlindedPath of a Bolt12Invoice, could cause the invoice's onion message to exceed the maximum size. The features are already checked before sending an invoice.
1 parent 7b86442 commit 33b6162

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

lightning/src/ln/offers_tests.rs

-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use crate::blinded_path::{BlindedPath, IntroductionNode};
4646
use crate::blinded_path::payment::{Bolt12OfferContext, Bolt12RefundContext, PaymentContext};
4747
use crate::events::{Event, MessageSendEventsProvider, PaymentPurpose};
4848
use crate::ln::channelmanager::{PaymentId, RecentPaymentDetails, Retry, self};
49-
use crate::ln::features::InvoiceRequestFeatures;
5049
use crate::ln::functional_test_utils::*;
5150
use crate::ln::msgs::{ChannelMessageHandler, Init, NodeAnnouncement, OnionMessage, OnionMessageHandler, RoutingMessageHandler, SocketAddress, UnsignedGossipMessage, UnsignedNodeAnnouncement};
5251
use crate::offers::invoice::Bolt12Invoice;
@@ -412,7 +411,6 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
412411
offer_id: offer.id(),
413412
invoice_request: InvoiceRequestFields {
414413
payer_id: invoice_request.payer_id(),
415-
features: InvoiceRequestFeatures::empty(),
416414
quantity: None,
417415
payer_note_truncated: None,
418416
},
@@ -564,7 +562,6 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
564562
offer_id: offer.id(),
565563
invoice_request: InvoiceRequestFields {
566564
payer_id: invoice_request.payer_id(),
567-
features: InvoiceRequestFeatures::empty(),
568565
quantity: None,
569566
payer_note_truncated: None,
570567
},
@@ -685,7 +682,6 @@ fn pays_for_offer_without_blinded_paths() {
685682
offer_id: offer.id(),
686683
invoice_request: InvoiceRequestFields {
687684
payer_id: invoice_request.payer_id(),
688-
features: InvoiceRequestFeatures::empty(),
689685
quantity: None,
690686
payer_note_truncated: None,
691687
},

lightning/src/offers/invoice_request.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -877,13 +877,12 @@ impl VerifiedInvoiceRequest {
877877
let InvoiceRequestContents {
878878
payer_id,
879879
inner: InvoiceRequestContentsWithoutPayerId {
880-
payer: _, offer: _, chain: _, amount_msats: _, features, quantity, payer_note
880+
payer: _, offer: _, chain: _, amount_msats: _, features: _, quantity, payer_note
881881
},
882882
} = &self.inner.contents;
883883

884884
InvoiceRequestFields {
885885
payer_id: *payer_id,
886-
features: features.clone(),
887886
quantity: *quantity,
888887
payer_note_truncated: payer_note.clone()
889888
.map(|mut s| { s.truncate(PAYER_NOTE_LIMIT); UntrustedString(s) }),
@@ -1125,9 +1124,6 @@ pub struct InvoiceRequestFields {
11251124
/// A possibly transient pubkey used to sign the invoice request.
11261125
pub payer_id: PublicKey,
11271126

1128-
/// Features pertaining to requesting an invoice.
1129-
pub features: InvoiceRequestFeatures,
1130-
11311127
/// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
11321128
pub quantity: Option<u64>,
11331129

@@ -1143,9 +1139,8 @@ impl Writeable for InvoiceRequestFields {
11431139
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
11441140
write_tlv_fields!(writer, {
11451141
(0, self.payer_id, required),
1146-
(2, WithoutLength(&self.features), required),
1147-
(4, self.quantity.map(|v| HighZeroBytesDroppedBigSize(v)), option),
1148-
(6, self.payer_note_truncated.as_ref().map(|s| WithoutLength(&s.0)), option),
1142+
(2, self.quantity.map(|v| HighZeroBytesDroppedBigSize(v)), option),
1143+
(4, self.payer_note_truncated.as_ref().map(|s| WithoutLength(&s.0)), option),
11491144
});
11501145
Ok(())
11511146
}
@@ -1155,14 +1150,13 @@ impl Readable for InvoiceRequestFields {
11551150
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
11561151
_init_and_read_len_prefixed_tlv_fields!(reader, {
11571152
(0, payer_id, required),
1158-
(2, features, (option, encoding: (InvoiceRequestFeatures, WithoutLength))),
1159-
(4, quantity, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
1160-
(6, payer_note_truncated, (option, encoding: (String, WithoutLength))),
1153+
(2, quantity, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
1154+
(4, payer_note_truncated, (option, encoding: (String, WithoutLength))),
11611155
});
1162-
let features = features.unwrap_or(InvoiceRequestFeatures::empty());
11631156

11641157
Ok(InvoiceRequestFields {
1165-
payer_id: payer_id.0.unwrap(), features, quantity,
1158+
payer_id: payer_id.0.unwrap(),
1159+
quantity,
11661160
payer_note_truncated: payer_note_truncated.map(|s| UntrustedString(s)),
11671161
})
11681162
}
@@ -2267,7 +2261,6 @@ mod tests {
22672261
fields,
22682262
InvoiceRequestFields {
22692263
payer_id: payer_pubkey(),
2270-
features: InvoiceRequestFeatures::empty(),
22712264
quantity: Some(1),
22722265
payer_note_truncated: Some(UntrustedString("0".repeat(PAYER_NOTE_LIMIT))),
22732266
}

0 commit comments

Comments
 (0)