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

Lightning.Protocol.BOLT9.Features

Description

Known feature table for the Lightning Network, per BOLT #9.

Synopsis

Feature

data Feature Source #

A known feature from the BOLT #9 specification.

Constructors

Feature 

Fields

Instances

Instances details
NFData Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

Methods

rnf :: Feature -> () #

Generic Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

Associated Types

type Rep Feature 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

type Rep Feature = D1 ('MetaData "Feature" "Lightning.Protocol.BOLT9.Features" "ppad-bolt9-0.0.1-SCTy7SY2nBJMXEGG76XgS" 'False) (C1 ('MetaCons "Feature" 'PrefixI 'True) ((S1 ('MetaSel ('Just "featureName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String) :*: S1 ('MetaSel ('Just "featureBaseBit") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word16)) :*: (S1 ('MetaSel ('Just "featureContexts") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Context]) :*: (S1 ('MetaSel ('Just "featureDependencies") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [String]) :*: S1 ('MetaSel ('Just "featureAssumed") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))))

Methods

from :: Feature -> Rep Feature x #

to :: Rep Feature x -> Feature #

Show Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

Eq Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

Methods

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

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

type Rep Feature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

type Rep Feature = D1 ('MetaData "Feature" "Lightning.Protocol.BOLT9.Features" "ppad-bolt9-0.0.1-SCTy7SY2nBJMXEGG76XgS" 'False) (C1 ('MetaCons "Feature" 'PrefixI 'True) ((S1 ('MetaSel ('Just "featureName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String) :*: S1 ('MetaSel ('Just "featureBaseBit") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word16)) :*: (S1 ('MetaSel ('Just "featureContexts") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Context]) :*: (S1 ('MetaSel ('Just "featureDependencies") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [String]) :*: S1 ('MetaSel ('Just "featureAssumed") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))))

Known feature

newtype KnownFeature Source #

A feature that is known to be in the BOLT #9 specification.

Constructed via knownFeatureByBit or knownFeatureByName, which validate that the feature exists in the known table.

Constructors

KnownFeature 

Fields

Instances

Instances details
NFData KnownFeature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

Methods

rnf :: KnownFeature -> () #

Generic KnownFeature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

Associated Types

type Rep KnownFeature 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

type Rep KnownFeature = D1 ('MetaData "KnownFeature" "Lightning.Protocol.BOLT9.Features" "ppad-bolt9-0.0.1-SCTy7SY2nBJMXEGG76XgS" 'True) (C1 ('MetaCons "KnownFeature" 'PrefixI 'True) (S1 ('MetaSel ('Just "unKnownFeature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Feature)))
Show KnownFeature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

Eq KnownFeature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

type Rep KnownFeature Source # 
Instance details

Defined in Lightning.Protocol.BOLT9.Features

type Rep KnownFeature = D1 ('MetaData "KnownFeature" "Lightning.Protocol.BOLT9.Features" "ppad-bolt9-0.0.1-SCTy7SY2nBJMXEGG76XgS" 'True) (C1 ('MetaCons "KnownFeature" 'PrefixI 'True) (S1 ('MetaSel ('Just "unKnownFeature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Feature)))

knownFeatureByBit :: Word16 -> Maybe KnownFeature Source #

Look up a known feature by bit number.

Accepts either the even (compulsory) or odd (optional) bit.

>>> fmap (featureName . unKnownFeature) (knownFeatureByBit 16)
Just "basic_mpp"
>>> knownFeatureByBit 999
Nothing

knownFeatureByName :: String -> Maybe KnownFeature Source #

Look up a known feature by its canonical name.

>>> fmap (featureName . unKnownFeature)
...       (knownFeatureByName "basic_mpp")
Just "basic_mpp"
>>> knownFeatureByName "nonexistent"
Nothing

Lookup

featureByBit :: Word16 -> Maybe Feature Source #

Look up a feature by bit number.

Accepts either the even (compulsory) or odd (optional) bit of the pair.

>>> fmap featureName (featureByBit 16)
Just "basic_mpp"
>>> fmap featureName (featureByBit 17)  -- odd bit also works
Just "basic_mpp"
>>> featureByBit 999
Nothing

featureByName :: String -> Maybe Feature Source #

Look up a feature by its canonical name.

>>> fmap featureBaseBit (featureByName "basic_mpp")
Just 16
>>> featureByName "nonexistent"
Nothing

Known features table

knownFeatures :: [Feature] Source #

The complete table of known features from BOLT #9.