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:
11
bip-0138.md
11
bip-0138.md
@@ -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.
|
`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`.
|
`DATA`: variable-length field whose encoding depends on `TYPE`.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user