Skip to content

BOLT 1: Clarify optionality of message format extension #1302

@tnull

Description

@tnull

BOLT 1 currently states:

## Lightning Message Format

After decryption, all Lightning messages are of the form:

1. `type`: a 2-byte big-endian field indicating the type of message
2. `payload`: a variable-length payload that comprises the remainder of
   the message and that conforms to a format matching the `type`
3. `extension`: an optional [TLV stream](#type-length-value-format)

The `type` field indicates how to interpret the `payload` field.
The format for each individual type is defined by a specification in this repository.

as well as

The messages are grouped logically into five groups, ordered by the most significant bit that is set:
...
  - Custom (types `32768`-`65535`): experimental and application-specific messages

A few observations here:

  • Stating that payload comprises the remainder of the message directly conflicts with there possibly being an extension in addition to said payload. If there is an extension, payload won't be the entire remainder.
  • Stating that the type field indicates how the payload should be interpreted doesn't say anything about whether it also defines how extension should be interpreted.
  • It's not entirely clear what 'an optional TLV stream' means. For who is it optional? Does the type define whether a reader should expect/support an optional extension, or is it expected that any application making use of custom messages is able to deal with such an extension being present (according to 'it's okay to be odd')?
  • In contrast what's stated at the end of the first excerpt, (custom) message types are not necessarily defined in the BOLTs. At the very least there a those listed in the mentioned issue as well as over at https://github.com/lightning/blips/blob/master/blip-0002.md#messages

It would be great to get some insights into these details, and maybe even clarify them in the spec. In particular, I'd like to understand whether custom messages are expected to span the remainder of the message or whether they are expected to be, e.g., length-prefixed to always be able to handle an extension that could potentially be added by some other protocol.

For context, I'm raising these questions since the LSPS0 protocol as defined in bLIP-50 currently uses custom messages with a type|payload scheme, assuming that payload is always the remainder of the custom message and valid JSON. Is this in compliance with BOLT 1 or would we need to be able to handle the optional TLV extension?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions