Support for custom feature bits (lightning-custom-message, features)

https://github.com/lightningdevkit/rust-lightning/pull/2204

Host: dunxen  -  PR author: jkczyz

Notes

  • There are various locations in LN structures where support for certain functionality is advertised and made possible, as enumerated in bLIP-0002:
    • Feature bits allows a node to publically advertise support for or requirement of a specific feature. Bits within the range 0-255 are reserved for BOLTs and so can not be used for custom features.
      • These feature bits can appear in the following contexts
        • init message (minimally sized feature field bitmask)
        • node_announcement message (minimally sized feature field bitmask)
        • channel_announcement message (minimally sized feature field bitmask)
        • BOLT 11 invoices (bLIPs only in range 256-5114 clarified by bLIPs#24
        • allowed_features field of a blinded path
    • LN message format: new message types can be used for custom features. Message types within the range 0-32767 are reserved for BOLTs. Custom features (bLIPs) must use types in the range 32768-65535.
    • TLV fields in BOLT messages: included in the trailing TLV stream of a BOLT message. bLIPs must use types greater than 65536.
  • PR2204 adds the methods provided_node_festures() and provided_init_features() to the CustomMessageHandler trait. Implementers are then able to set and provide their own features.
  • The PR also adds functionality for setting feature bits that are unknown to LDK with Features::set_custom_bit(), but the bit must be in the custom range defined by bLIP 2 of course.

Questions

  1. Did you review the PR? Concept ACK, approach ACK, tested ACK, or NACK?
  2. What is the CustomMessageHandler trait and where do we delegate message handling to an implementer of this trait?
  3. Why are custom feature bits in the invoice (I) context limited to the range 256-5114? Why don’t other feature contexts, such as init, node_announcement, etc, have this specific restriction.
  4. Other than specified in the notes, there is another restriction that applies to Features::set_custom_bit() for bits in the custom range. What is it and how is it identified?