1
0
mirror of https://github.com/bitcoin/bips.git synced 2026-10-19 19:29:18 +00:00

bip-138 document why content LENGTH is mandatory

This commit is contained in:
pythcoiner
2026-07-14 23:24:16 -04:00
parent 9f1be26e2f
commit 1de39be4e3

View File

@@ -369,7 +369,16 @@ remaining bytes are `PADDING`. A `PAYLOAD` MUST contain at least one item (see
`LENGTH`: variable-length integer representing the length of `DATA` in bytes.
For all `TYPE` values except `0x01`, `LENGTH` MUST be present.
For all `TYPE` values except `0x01`, `LENGTH` MUST be present.[^length-required]
[^length-required]: **Why is `LENGTH` mandatory?**
`LENGTH` is what lets a parser skip a content type it does not implement and still
read the items that follow; without it, the parser cannot know where `DATA` ends.
A string note placed before a descriptor, for example, must not stop an
implementation that only handles descriptors from recovering that descriptor. A
type whose `DATA` is always empty still carries a zero `LENGTH` for this reason.
`0x01` is exempt because every implementation handles it, so it is never skipped
blindly.
`DATA`: variable-length field whose encoding depends on `TYPE`.