From: Jeffrey Czyz Date: Thu, 17 Oct 2024 22:51:54 +0000 (-0500) Subject: Include experimental TLV records when verifying X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=bcc7c1dc1d8e08c93b3f94db509ee4a0ed692608;p=rust-lightning 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. --- diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index 894c45d42..92b75baaf 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -1147,6 +1147,9 @@ impl InvoiceContents { &self, bytes: &[u8], metadata: &Metadata, key: &ExpandedKey, iv_bytes: &[u8; IV_LEN], secp_ctx: &Secp256k1 ) -> Result { + const EXPERIMENTAL_TYPES: core::ops::Range = + EXPERIMENTAL_OFFER_TYPES.start..EXPERIMENTAL_INVOICE_REQUEST_TYPES.end; + let offer_records = TlvStream::new(bytes).range(OFFER_TYPES); let invreq_records = TlvStream::new(bytes).range(INVOICE_REQUEST_TYPES).filter(|record| { match record.r#type { @@ -1155,7 +1158,8 @@ impl InvoiceContents { _ => true, } }); - let tlv_stream = offer_records.chain(invreq_records); + let experimental_records = TlvStream::new(bytes).range(EXPERIMENTAL_TYPES); + let tlv_stream = offer_records.chain(invreq_records).chain(experimental_records); let signing_pubkey = self.payer_signing_pubkey(); signer::verify_payer_metadata( diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index c33d6510f..810787265 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -963,7 +963,9 @@ impl OfferContents { OFFER_ISSUER_ID_TYPE => !metadata.derives_recipient_keys(), _ => true, } - }); + }) + .chain(TlvStream::new(bytes).range(EXPERIMENTAL_OFFER_TYPES)); + let signing_pubkey = match self.issuer_signing_pubkey() { Some(signing_pubkey) => signing_pubkey, None => return Err(()),