fix(js): reject empty offer_description TLV (BOLT12)#35
Open
vincenzopalazzo wants to merge 1 commit into
Open
Conversation
BOLT12 treats descriptionless offers as omitting type 10 entirely. A zero-length offer_description must not satisfy the requirement that fixed-amount offers include a complete description. - validateOffer: error on empty offer_description - extractOfferFields: omit description when TLV payload is empty - test vector: amount + empty description offer is invalid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligns
validateOffer()with BOLT12 offer encoding:offer_amountis set, writers MUST setoffer_descriptionto a complete description.offer_amountis set andoffer_descriptionis not set.A type-10 TLV with zero-length payload is not “descriptionless” — writers should omit the TLV entirely (as in minimal amount-less offers).
Changes
js/src/offer.ts: rejectInvalid: empty offer_descriptionwhen TLV 10 has length 0; only count non-empty descriptions for the amount/description semantic check.js/src/fields.ts: do not surfacedescriptionfor empty TLV 10 payloads.test-vectors/offers-bolt-test.json: add invalid vector (fixed amount + empty description).Testing
Context
Decoded a real-world offer that had
offer_amount+offer_descriptionwith length 0; it previously passed validation incorrectly.