]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Include experimental TLV records when verifying
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 17 Oct 2024 22:51:54 +0000 (17:51 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Tue, 5 Nov 2024 00:00:22 +0000 (18:00 -0600)
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.

lightning/src/offers/invoice.rs
lightning/src/offers/offer.rs

index 894c45d42f28c29878b47f8d13b89421a5e54fe4..92b75baafbff67964a361b957c1020a9fc470773 100644 (file)
@@ -1147,6 +1147,9 @@ impl InvoiceContents {
                &self, bytes: &[u8], metadata: &Metadata, key: &ExpandedKey, iv_bytes: &[u8; IV_LEN],
                secp_ctx: &Secp256k1<T>
        ) -> Result<PaymentId, ()> {
+               const EXPERIMENTAL_TYPES: core::ops::Range<u64> =
+                       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(
index c33d6510fddfcb1497bf01f5624e664793b6ecf6..81078726591c6522b483feab939a92bf2d541e44 100644 (file)
@@ -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(()),