Skip to content

Abstraction of ChannelId type #2408

Closed
@optout21

Description

@optout21

Channel IDs are 32-byte IDs, and are represented simply as [u8; 32] in LDK.
A new type could be introduced, as an abstraction of the channel ID type. This would be a refactoring.

Rationale:

  • better representation of a type representing a channel ID (abstraction)
  • potential for indicating when a channel ID is only temporary
  • separation of anticipated 'new' channel IDs that are not based on outpoint, but on revocation points, coming with Dual funded / Splicing features (see Dual-funded channels and Splicing Project Tracking #1621 ).

Proposed change:
a ChannelId enum, with values for outpoint-based and temporary IDs (and later revocation-based), all wrapping [u8; 32].

Alternatives of increasing complexity / code change needed:

  1. (current state) use native type [u8; 32]
  2. a named type alias (type ChannelId = [u8; 32]). Can be used interchangebly.
  3. a struct wrapping the native type, as 1-element tuple, struct ChannelId(pub [u8; 32])), similar to PaymentId. Construction and usage sites need slight modification.
  4. a struct wrapping the data in a private field, with accessor and special construction methods.
  5. an enum, with values for outpoint-based, temporary (and later revocation-based), all wrapping 32-byte array.
  6. (not recommended) a trait and different implementations for different variants.

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