Skip to content

Commit 906a6fb

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 4a93699 commit 906a6fb

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
@@ -1109,6 +1109,9 @@ impl InvoiceContents {
11091109
&self, bytes: &[u8], metadata: &Metadata, key: &ExpandedKey, iv_bytes: &[u8; IV_LEN],
11101110
secp_ctx: &Secp256k1<T>
11111111
) -> Result<PaymentId, ()> {
1112+
const EXPERIMENTAL_TYPES: core::ops::Range<u64> =
1113+
EXPERIMENTAL_OFFER_TYPES.start..EXPERIMENTAL_INVOICE_REQUEST_TYPES.end;
1114+
11121115
let offer_records = TlvStream::new(bytes).range(OFFER_TYPES);
11131116
let invreq_records = TlvStream::new(bytes).range(INVOICE_REQUEST_TYPES).filter(|record| {
11141117
match record.r#type {
@@ -1117,7 +1120,8 @@ impl InvoiceContents {
11171120
_ => true,
11181121
}
11191122
});
1120-
let tlv_stream = offer_records.chain(invreq_records);
1123+
let experimental_records = TlvStream::new(bytes).range(EXPERIMENTAL_TYPES);
1124+
let tlv_stream = offer_records.chain(invreq_records).chain(experimental_records);
11211125

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