ppad-bolt9-0.1.0: Feature flags per BOLT #9
Copyright(c) 2025 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Lightning.Protocol.BOLT9

Description

Feature flags for the Lightning Network, per BOLT #9.

A feature vector is a big-endian bit field. Features are assigned pairs of bits: setting the even bit means the feature is required, setting the odd bit means it is optional (it's ok to be odd).

The examples below assume:

>>> :set -XOverloadedStrings
>>> import Lightning.Protocol.BOLT9

Build a vector, check it before sending it, and render it:

>>> let fv = set_feature_with_deps OptionZeroconf Optional empty
>>> list_features fv
[(OptionScidAlias,Optional),(OptionZeroconf,Optional)]
>>> validate_local InitContext fv
Right ()
>>> render fv
"\b\128\NUL\NUL\NUL\NUL\NUL"

Check a vector received from a peer:

>>> validate_remote InitContext (parse "\DLE\NUL\NUL")
Left (UnknownBit 20 :| [])
>>> validate_remote InitContext (parse "\STX\NUL\NUL")
Right ()
Synopsis

Feature vectors

data FeatureVector Source #

A feature vector.

Bit 0 is the least significant bit of the last byte. A vector produced by parse keeps its bytes exactly, so render gives them back unchanged (signatures over gossip messages cover them). Every other operation produces a minimally-encoded vector, i.e. one without leading zero bytes.

Equality ignores leading zero bytes.

>>> parse "\NUL\STX" == parse "\STX"
True
>>> set_bit 1 empty
parse "\STX"

Instances

Instances details
NFData FeatureVector Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

rnf :: FeatureVector -> () #

Show FeatureVector Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Eq FeatureVector Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

parse :: ByteString -> FeatureVector Source #

Parse a feature vector from its wire bytes. Every byte string is a valid feature vector.

>>> test_bit 9 (parse "\STX\NUL")
True

render :: FeatureVector -> ByteString Source #

The wire bytes of a feature vector: the original bytes of a vector produced by parse, and the minimal encoding of any other.

>>> render (parse "\NUL\STX")
"\NUL\STX"
>>> render (union (parse "\NUL\STX") empty)
"\STX"

empty :: FeatureVector Source #

The empty feature vector.

>>> render empty
""

union :: FeatureVector -> FeatureVector -> FeatureVector Source #

The bitwise OR of two feature vectors.

BOLT #1 requires the receiver of an init message to combine its globalfeatures and features fields this way.

>>> set_bits (union (parse "\STX") (parse "\SOH\NUL"))
[1,8]

Bits

set_bit :: Int -> FeatureVector -> FeatureVector Source #

Set the bit at the given index. Negative indices are ignored.

>>> render (set_bit 9 empty)
"\STX\NUL"

clear_bit :: Int -> FeatureVector -> FeatureVector Source #

Clear the bit at the given index. Negative indices are ignored.

>>> render (clear_bit 9 (parse "\STX\SOH"))
"\SOH"

test_bit :: Int -> FeatureVector -> Bool Source #

Test the bit at the given index. Negative indices are never set.

>>> test_bit 9 (parse "\STX\NUL")
True
>>> test_bit 8 (parse "\STX\NUL")
False

set_bits :: FeatureVector -> [Int] Source #

The indices of all set bits, in ascending order.

>>> set_bits (parse "\STX\NUL\SOH")
[0,17]

Known features

data Feature Source #

The features assigned in the BOLT #9 table.

Constructors

OptionDataLossProtect

0/1 option_data_loss_protect

OptionUpfrontShutdownScript

4/5 option_upfront_shutdown_script

GossipQueries

6/7 gossip_queries

VarOnionOptin

8/9 var_onion_optin

GossipQueriesEx

10/11 gossip_queries_ex

OptionStaticRemotekey

12/13 option_static_remotekey

PaymentSecret

14/15 payment_secret

BasicMpp

16/17 basic_mpp

OptionSupportLargeChannel

18/19 option_support_large_channel

OptionAnchors

22/23 option_anchors

OptionRouteBlinding

24/25 option_route_blinding

OptionShutdownAnysegwit

26/27 option_shutdown_anysegwit

OptionDualFund

28/29 option_dual_fund

OptionQuiesce

34/35 option_quiesce

OptionAttributionData

36/37 option_attribution_data

OptionOnionMessages

38/39 option_onion_messages

ZeroFeeCommitments

40/41 zero_fee_commitments

OptionProvideStorage

42/43 option_provide_storage

OptionChannelType

44/45 option_channel_type

OptionScidAlias

46/47 option_scid_alias

OptionPaymentMetadata

48/49 option_payment_metadata

OptionZeroconf

50/51 option_zeroconf

OptionSimpleClose

60/61 option_simple_close

OptionSplice

62/63 option_splice

OptionOnionMessagesOnlyChannels

66/67 option_onion_messages_only_channels

Instances

Instances details
NFData Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

rnf :: Feature -> () #

Generic Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Associated Types

type Rep Feature 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep Feature = D1 ('MetaData "Feature" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) ((((C1 ('MetaCons "OptionDataLossProtect" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OptionUpfrontShutdownScript" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "GossipQueries" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "VarOnionOptin" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "GossipQueriesEx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionStaticRemotekey" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "PaymentSecret" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BasicMpp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionSupportLargeChannel" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "OptionAnchors" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OptionRouteBlinding" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionShutdownAnysegwit" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "OptionDualFund" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OptionQuiesce" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionAttributionData" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "OptionOnionMessages" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ZeroFeeCommitments" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionProvideStorage" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "OptionChannelType" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OptionScidAlias" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionPaymentMetadata" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OptionZeroconf" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionSimpleClose" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OptionSplice" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionOnionMessagesOnlyChannels" 'PrefixI 'False) (U1 :: Type -> Type))))))

Methods

from :: Feature -> Rep Feature x #

to :: Rep Feature x -> Feature #

Show Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Eq Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

(==) :: Feature -> Feature -> Bool #

(/=) :: Feature -> Feature -> Bool #

Ord Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep Feature = D1 ('MetaData "Feature" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) ((((C1 ('MetaCons "OptionDataLossProtect" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OptionUpfrontShutdownScript" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "GossipQueries" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "VarOnionOptin" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "GossipQueriesEx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionStaticRemotekey" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "PaymentSecret" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BasicMpp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionSupportLargeChannel" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "OptionAnchors" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OptionRouteBlinding" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionShutdownAnysegwit" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "OptionDualFund" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OptionQuiesce" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionAttributionData" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "OptionOnionMessages" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ZeroFeeCommitments" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionProvideStorage" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "OptionChannelType" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OptionScidAlias" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionPaymentMetadata" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "OptionZeroconf" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionSimpleClose" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "OptionSplice" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OptionOnionMessagesOnlyChannels" 'PrefixI 'False) (U1 :: Type -> Type))))))

known_features :: [Feature] Source #

All known features, in bit order.

>>> length known_features
25

feature_by_bit :: Int -> Maybe Feature Source #

The feature that a bit (even or odd) belongs to, if any.

>>> feature_by_bit 16
Just BasicMpp
>>> feature_by_bit 17
Just BasicMpp
>>> feature_by_bit 20
Nothing

feature_bit :: Feature -> Int Source #

A feature's even (required) bit. Its odd (optional) bit is the next one up.

>>> feature_bit BasicMpp
16

feature_name :: Feature -> String Source #

A feature's name in the BOLT #9 table.

>>> feature_name BasicMpp
"basic_mpp"

feature_contexts :: Feature -> [Context] Source #

The contexts the BOLT #9 table lists for a feature, in table order. The list is empty for ASSUMED features and for GossipQueries.

>>> feature_contexts BasicMpp
[InitContext,NodeContext,InvoiceContext]
>>> feature_contexts PaymentSecret
[]

feature_dependencies :: Feature -> [Feature] Source #

A feature's direct dependencies.

>>> feature_dependencies OptionZeroconf
[OptionScidAlias]

feature_assumed :: Feature -> Bool Source #

Whether BOLT #9 marks a feature ASSUMED, i.e. supported by all nodes.

>>> feature_assumed PaymentSecret
True

Feature operations

data FeatureLevel Source #

The level at which a feature is set.

Constructors

Required

the even bit is set

Optional

the odd bit is set

Instances

Instances details
NFData FeatureLevel Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

rnf :: FeatureLevel -> () #

Generic FeatureLevel Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Associated Types

type Rep FeatureLevel 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep FeatureLevel = D1 ('MetaData "FeatureLevel" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) (C1 ('MetaCons "Required" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Optional" 'PrefixI 'False) (U1 :: Type -> Type))
Show FeatureLevel Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Eq FeatureLevel Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Ord FeatureLevel Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep FeatureLevel Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep FeatureLevel = D1 ('MetaData "FeatureLevel" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) (C1 ('MetaCons "Required" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Optional" 'PrefixI 'False) (U1 :: Type -> Type))

set_feature :: Feature -> FeatureLevel -> FeatureVector -> FeatureVector Source #

Set a feature at the given level, clearing the other bit of its pair.

>>> set_bits (set_feature BasicMpp Optional empty)
[17]
>>> set_bits (set_feature BasicMpp Required (set_bit 17 empty))
[16]

set_feature_with_deps :: Feature -> FeatureLevel -> FeatureVector -> FeatureVector Source #

Set a feature at the given level, together with its transitive dependencies (ASSUMED ones included). Dependencies that are not yet set are set at the same level; those already set keep theirs.

>>> list_features (set_feature_with_deps BasicMpp Optional empty)
[(PaymentSecret,Optional),(BasicMpp,Optional)]

clear_feature :: Feature -> FeatureVector -> FeatureVector Source #

Clear both bits of a feature.

>>> clear_feature BasicMpp (set_feature BasicMpp Optional empty)
parse ""

test_feature :: Feature -> FeatureVector -> Maybe FeatureLevel Source #

The level at which a feature is set, if it is.

A feature with both bits set is Required, as BOLT #9 directs the receiver to treat it.

>>> test_feature BasicMpp (set_bit 17 empty)
Just Optional
>>> test_feature BasicMpp (set_bit 16 (set_bit 17 empty))
Just Required
>>> test_feature BasicMpp empty
Nothing

list_features :: FeatureVector -> [(Feature, FeatureLevel)] Source #

The known features set in a vector, in bit order.

>>> list_features (parse "\SOH\128\NUL")
[(PaymentSecret,Optional),(BasicMpp,Required)]

Validation

data Context Source #

A field in which feature bits are presented: the values of the Context column of the BOLT #9 table.

The table's C- and C+ are not further contexts. They mark a feature presented in channel_announcement as always optional or always required. No feature at the implemented spec revision is presented in channel_announcement in any form.

Constructors

InitContext

I: the init message

NodeContext

N: node_announcement

ChannelContext

C: channel_announcement

InvoiceContext

9: BOLT #11 invoices

BlindedContext

B: allowed_features of a blinded path

ChannelTypeContext

T: the channel_type field

Instances

Instances details
NFData Context Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

rnf :: Context -> () #

Generic Context Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Associated Types

type Rep Context 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep Context = D1 ('MetaData "Context" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) ((C1 ('MetaCons "InitContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NodeContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ChannelContext" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "InvoiceContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BlindedContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ChannelTypeContext" 'PrefixI 'False) (U1 :: Type -> Type))))

Methods

from :: Context -> Rep Context x #

to :: Rep Context x -> Context #

Show Context Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Eq Context Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

(==) :: Context -> Context -> Bool #

(/=) :: Context -> Context -> Bool #

Ord Context Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep Context Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep Context = D1 ('MetaData "Context" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) ((C1 ('MetaCons "InitContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NodeContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ChannelContext" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "InvoiceContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BlindedContext" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ChannelTypeContext" 'PrefixI 'False) (U1 :: Type -> Type))))

data ValidationError Source #

A rule a feature vector breaks.

Constructors

UnknownBit !Int

a bit belonging to no known feature is set

BothBitsSet !Feature

both bits of a feature are set

ContextNotAllowed !Feature !Context

a feature is set in a context that doesn't present it

MissingDependency !Feature !Feature

a set feature (first) lacks a dependency (second)

InvalidChannelType

a channel_type is not a type that BOLT #2 defines

Instances

Instances details
NFData ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

rnf :: ValidationError -> () #

Generic ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Show ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Eq ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

validate_local :: Context -> FeatureVector -> Either (NonEmpty ValidationError) () Source #

Validate a feature vector that we're about to send in the given context, per the origin requirements of BOLT #9 and BOLT #1.

For ChannelTypeContext, the vector must be a channel type that BOLT #2 defines (see channel_type). For every other context, checks that:

  • no bit outside the known features is set;
  • no feature has both bits set;
  • each set feature is presented in the context. A feature with an empty Context column (the ASSUMED features and GossipQueries) is accepted in InitContext, NodeContext and InvoiceContext, where deployed nodes still present it;
  • each set feature's dependencies are set. A dependency on an ASSUMED feature counts as met even when its bits are clear.

Errors are reported in that order. No known feature is presented in ChannelContext or BlindedContext, so only the empty vector passes there (as BOLT #4 requires of allowed_features).

>>> validate_local InitContext (set_feature OptionZeroconf Optional empty)
Left (MissingDependency OptionZeroconf OptionScidAlias :| [])
>>> validate_local InitContext (set_feature BasicMpp Optional empty)
Right ()
>>> validate_local InitContext (set_bit 101 empty)
Left (UnknownBit 101 :| [])

validate_remote :: Context -> FeatureVector -> Either (NonEmpty ValidationError) () Source #

Validate a feature vector received in the given context, per the receiver requirements for that context:

  • InitContext (BOLT #1) and InvoiceContext (BOLT #11): no unknown even bit is set, and each set feature's dependencies are set (ASSUMED dependencies count as met).
  • NodeContext and ChannelContext (BOLT #7): no unknown even bit is set. A failure here means the node or channel must not be routed through; the announcement itself is still valid.
  • BlindedContext (BOLT #4): no unknown bit is set, odd or even.
  • ChannelTypeContext (BOLT #2): the vector is a defined channel type (see channel_type).

Unknown odd bits are otherwise ignored. A feature with both bits set is not an error; it counts as Required (see test_feature). Nor is a known feature outside its listed contexts, since that rule binds only the sender.

>>> validate_remote InitContext (set_bit 101 empty)
Right ()
>>> validate_remote InitContext (set_bit 100 empty)
Left (UnknownBit 100 :| [])
>>> validate_remote BlindedContext (set_bit 101 empty)
Left (UnknownBit 101 :| [])

Channel types

data ChannelType Source #

A channel type, per BOLT #2: a basic type plus any of the OptionScidAlias and OptionZeroconf variations.

Channel types are an enumeration that reuses even feature bits; they aren't subject to the dependency or context rules for feature vectors. BOLT #2 also forbids OptionScidAlias in the channel type of a channel to be announced, which needs the announce_channel flag to check.

Instances

Instances details
NFData ChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

rnf :: ChannelType -> () #

Generic ChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Associated Types

type Rep ChannelType 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep ChannelType = D1 ('MetaData "ChannelType" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) (C1 ('MetaCons "ChannelType" 'PrefixI 'True) (S1 ('MetaSel ('Just "ct_basic") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 BasicChannelType) :*: (S1 ('MetaSel ('Just "ct_scid_alias") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "ct_zeroconf") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))))
Show ChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Eq ChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep ChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep ChannelType = D1 ('MetaData "ChannelType" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) (C1 ('MetaCons "ChannelType" 'PrefixI 'True) (S1 ('MetaSel ('Just "ct_basic") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 BasicChannelType) :*: (S1 ('MetaSel ('Just "ct_scid_alias") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "ct_zeroconf") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))))

data BasicChannelType Source #

The basic channel types of BOLT #2.

Instances

Instances details
NFData BasicChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Methods

rnf :: BasicChannelType -> () #

Generic BasicChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Associated Types

type Rep BasicChannelType 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep BasicChannelType = D1 ('MetaData "BasicChannelType" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) (C1 ('MetaCons "BasicStaticRemotekey" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BasicAnchors" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BasicZeroFeeCommitments" 'PrefixI 'False) (U1 :: Type -> Type)))
Show BasicChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Eq BasicChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

Ord BasicChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep BasicChannelType Source # 
Instance details

Defined in Lightning.Protocol.BOLT9

type Rep BasicChannelType = D1 ('MetaData "BasicChannelType" "Lightning.Protocol.BOLT9" "ppad-bolt9-0.1.0-2pi7ArXFPy5EEr7bj10TmI" 'False) (C1 ('MetaCons "BasicStaticRemotekey" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BasicAnchors" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BasicZeroFeeCommitments" 'PrefixI 'False) (U1 :: Type -> Type)))

channel_type :: FeatureVector -> Maybe ChannelType Source #

The channel type that a channel_type vector encodes, if it is a defined one. Leading zero bytes are ignored.

>>> let zeroconf = ChannelType BasicStaticRemotekey False True
>>> channel_type (parse "\EOT\NUL\NUL\NUL\NUL\DLE\NUL") == Just zeroconf
True
>>> channel_type (set_bit 13 empty)
Nothing

channel_type_features :: ChannelType -> FeatureVector Source #

The channel_type vector for a channel type.

>>> let anchors = ChannelType BasicAnchors False False
>>> render (channel_type_features anchors)
"@\DLE\NUL"