Skip to content

Commit bcc7c1d

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 63c687f commit bcc7c1d

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
@@ -1147,6 +1147,9 @@ impl InvoiceContents {
11471147
&self, bytes: &[u8], metadata: &Metadata, key: &ExpandedKey, iv_bytes: &[u8; IV_LEN],
11481148
secp_ctx: &Secp256k1<T>
11491149
) -> Result<PaymentId, ()> {
1150+
const EXPERIMENTAL_TYPES: core::ops::Range<u64> =
1151+
EXPERIMENTAL_OFFER_TYPES.start..EXPERIMENTAL_INVOICE_REQUEST_TYPES.end;
1152+
11501153
let offer_records = TlvStream::new(bytes).range(OFFER_TYPES);
11511154
let invreq_records = TlvStream::new(bytes).range(INVOICE_REQUEST_TYPES).filter(|record| {
11521155
match record.r#type {
@@ -1155,7 +1158,8 @@ impl InvoiceContents {
11551158
_ => true,
11561159
}
11571160
});
1158-
let tlv_stream = offer_records.chain(invreq_records);
1161+
let experimental_records = TlvStream::new(bytes).range(EXPERIMENTAL_TYPES);
1162+
let tlv_stream = offer_records.chain(invreq_records).chain(experimental_records);
11591163

11601164
let signing_pubkey = self.payer_signing_pubkey();
11611165
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)