Skip to content

Commit 6b5c198

Browse files
committed
Include experimental TLV records when verifying
Upcoming commits will allow parsing BOLT12 messages that include TLV records in the experimental range. Include these ranges when verifying messages since they will be included in the message bytes.
1 parent 1f35a6b commit 6b5c198

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lightning/src/offers/invoice.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,9 @@ impl InvoiceContents {
11371137
&self, bytes: &[u8], metadata: &Metadata, key: &ExpandedKey, iv_bytes: &[u8; IV_LEN],
11381138
secp_ctx: &Secp256k1<T>
11391139
) -> Result<PaymentId, ()> {
1140+
const EXPERIMENTAL_TYPES: core::ops::Range<u64> =
1141+
EXPERIMENTAL_OFFER_TYPES.start..EXPERIMENTAL_INVOICE_REQUEST_TYPES.end;
1142+
11401143
let offer_records = TlvStream::new(bytes).range(OFFER_TYPES);
11411144
let invreq_records = TlvStream::new(bytes).range(INVOICE_REQUEST_TYPES).filter(|record| {
11421145
match record.r#type {
@@ -1145,7 +1148,8 @@ impl InvoiceContents {
11451148
_ => true,
11461149
}
11471150
});
1148-
let tlv_stream = offer_records.chain(invreq_records);
1151+
let experimental_records = TlvStream::new(bytes).range(EXPERIMENTAL_TYPES);
1152+
let tlv_stream = offer_records.chain(invreq_records).chain(experimental_records);
11491153

11501154
let signing_pubkey = self.payer_signing_pubkey();
11511155
signer::verify_payer_metadata(

lightning/src/offers/offer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,9 @@ impl OfferContents {
963963
OFFER_ISSUER_ID_TYPE => !metadata.derives_recipient_keys(),
964964
_ => true,
965965
}
966-
});
966+
})
967+
.chain(TlvStream::new(bytes).range(EXPERIMENTAL_OFFER_TYPES));
968+
967969
let signing_pubkey = match self.issuer_signing_pubkey() {
968970
Some(signing_pubkey) => signing_pubkey,
969971
None => return Err(()),

0 commit comments

Comments
 (0)