| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Lightning.Protocol.BOLT1.Message
Description
Message types for BOLT #1.
Synopsis
- data MsgType
- msgTypeWord :: MsgType -> Word16
- parseMsgType :: Word16 -> MsgType
- data ChannelId
- channelId :: ByteString -> Maybe ChannelId
- unChannelId :: ChannelId -> ByteString
- allChannels :: ChannelId
- data Init = Init {
- initGlobalFeatures :: !ByteString
- initFeatures :: !ByteString
- initTlvs :: ![InitTlv]
- data Error = Error {}
- data Warning = Warning {}
- data Ping = Ping {}
- data Pong = Pong {}
- data PeerStorage = PeerStorage {}
- data PeerStorageRetrieval = PeerStorageRetrieval {}
- data Message
- messageType :: Message -> MsgType
- data Envelope = Envelope {
- envType :: !MsgType
- envPayload :: !ByteString
- envExtension :: !(Maybe TlvStream)
Message types
BOLT #1 message type codes.
Constructors
| MsgInit | 16 |
| MsgError | 17 |
| MsgPing | 18 |
| MsgPong | 19 |
| MsgWarning | 1 |
| MsgPeerStorage | 7 |
| MsgPeerStorageRet | 9 |
| MsgUnknown !Word16 | Unknown type |
Instances
msgTypeWord :: MsgType -> Word16 Source #
Get the numeric type code for a message type.
parseMsgType :: Word16 -> MsgType Source #
Parse a message type from a word.
Channel identifiers
A 32-byte channel identifier.
Use channelId to construct, which validates the length.
Use allChannels for connection-level errors (all-zeros channel ID).
Instances
| NFData ChannelId Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| Generic ChannelId Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show ChannelId Source # | |||||
| Eq ChannelId Source # | |||||
| type Rep ChannelId Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep ChannelId = D1 ('MetaData "ChannelId" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'True) (C1 ('MetaCons "ChannelId" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
channelId :: ByteString -> Maybe ChannelId Source #
Construct a ChannelId from a 32-byte ByteString.
Returns Nothing if the input is not exactly 32 bytes.
>>>channelId (BS.replicate 32 0x00)Just (ChannelId "\NUL\NUL...")>>>channelId "too short"Nothing
unChannelId :: ChannelId -> ByteString Source #
Extract the raw bytes from a ChannelId.
allChannels :: ChannelId Source #
The all-zeros channel ID, used for connection-level errors.
Per BOLT #1, setting channel_id to all zeros means the error applies to the connection rather than a specific channel.
Setup messages
The init message (type 16).
Constructors
| Init | |
Fields
| |
Instances
| NFData Init Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| Generic Init Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show Init Source # | |||||
| Eq Init Source # | |||||
| type Rep Init Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep Init = D1 ('MetaData "Init" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (C1 ('MetaCons "Init" 'PrefixI 'True) (S1 ('MetaSel ('Just "initGlobalFeatures") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: (S1 ('MetaSel ('Just "initFeatures") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "initTlvs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [InitTlv])))) | |||||
The error message (type 17).
Constructors
| Error | |
Fields
| |
Instances
| NFData Error Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| Generic Error Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show Error Source # | |||||
| Eq Error Source # | |||||
| type Rep Error Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep Error = D1 ('MetaData "Error" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (C1 ('MetaCons "Error" 'PrefixI 'True) (S1 ('MetaSel ('Just "errorChannelId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChannelId) :*: S1 ('MetaSel ('Just "errorData") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) | |||||
The warning message (type 1).
Constructors
| Warning | |
Fields | |
Instances
| NFData Warning Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| Generic Warning Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show Warning Source # | |||||
| Eq Warning Source # | |||||
| type Rep Warning Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep Warning = D1 ('MetaData "Warning" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (C1 ('MetaCons "Warning" 'PrefixI 'True) (S1 ('MetaSel ('Just "warningChannelId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChannelId) :*: S1 ('MetaSel ('Just "warningData") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) | |||||
Control messages
The ping message (type 18).
Constructors
| Ping | |
Fields
| |
Instances
| NFData Ping Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| Generic Ping Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show Ping Source # | |||||
| Eq Ping Source # | |||||
| type Rep Ping Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep Ping = D1 ('MetaData "Ping" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (C1 ('MetaCons "Ping" 'PrefixI 'True) (S1 ('MetaSel ('Just "pingNumPongBytes") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word16) :*: S1 ('MetaSel ('Just "pingIgnored") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) | |||||
The pong message (type 19).
Constructors
| Pong | |
Fields | |
Instances
| NFData Pong Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| Generic Pong Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show Pong Source # | |||||
| Eq Pong Source # | |||||
| type Rep Pong Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep Pong = D1 ('MetaData "Pong" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (C1 ('MetaCons "Pong" 'PrefixI 'True) (S1 ('MetaSel ('Just "pongIgnored") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) | |||||
Peer storage messages
data PeerStorage Source #
The peer_storage message (type 7).
Constructors
| PeerStorage | |
Fields | |
Instances
| NFData PeerStorage Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Methods rnf :: PeerStorage -> () # | |||||
| Generic PeerStorage Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show PeerStorage Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Methods showsPrec :: Int -> PeerStorage -> ShowS # show :: PeerStorage -> String # showList :: [PeerStorage] -> ShowS # | |||||
| Eq PeerStorage Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| type Rep PeerStorage Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep PeerStorage = D1 ('MetaData "PeerStorage" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (C1 ('MetaCons "PeerStorage" 'PrefixI 'True) (S1 ('MetaSel ('Just "peerStorageBlob") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) | |||||
data PeerStorageRetrieval Source #
The peer_storage_retrieval message (type 9).
Constructors
| PeerStorageRetrieval | |
Fields | |
Instances
| NFData PeerStorageRetrieval Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Methods rnf :: PeerStorageRetrieval -> () # | |||||
| Generic PeerStorageRetrieval Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
Methods from :: PeerStorageRetrieval -> Rep PeerStorageRetrieval x # to :: Rep PeerStorageRetrieval x -> PeerStorageRetrieval # | |||||
| Show PeerStorageRetrieval Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Methods showsPrec :: Int -> PeerStorageRetrieval -> ShowS # show :: PeerStorageRetrieval -> String # showList :: [PeerStorageRetrieval] -> ShowS # | |||||
| Eq PeerStorageRetrieval Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Methods (==) :: PeerStorageRetrieval -> PeerStorageRetrieval -> Bool # (/=) :: PeerStorageRetrieval -> PeerStorageRetrieval -> Bool # | |||||
| type Rep PeerStorageRetrieval Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep PeerStorageRetrieval = D1 ('MetaData "PeerStorageRetrieval" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (C1 ('MetaCons "PeerStorageRetrieval" 'PrefixI 'True) (S1 ('MetaSel ('Just "peerStorageRetrievalBlob") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) | |||||
Message envelope
All BOLT #1 messages.
Constructors
| MsgInitVal !Init | |
| MsgErrorVal !Error | |
| MsgWarningVal !Warning | |
| MsgPingVal !Ping | |
| MsgPongVal !Pong | |
| MsgPeerStorageVal !PeerStorage | |
| MsgPeerStorageRetrievalVal !PeerStorageRetrieval |
Instances
| NFData Message Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| Generic Message Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show Message Source # | |||||
| Eq Message Source # | |||||
| type Rep Message Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep Message = D1 ('MetaData "Message" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) ((C1 ('MetaCons "MsgInitVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Init)) :+: (C1 ('MetaCons "MsgErrorVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Error)) :+: C1 ('MetaCons "MsgWarningVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Warning)))) :+: ((C1 ('MetaCons "MsgPingVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Ping)) :+: C1 ('MetaCons "MsgPongVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Pong))) :+: (C1 ('MetaCons "MsgPeerStorageVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PeerStorage)) :+: C1 ('MetaCons "MsgPeerStorageRetrievalVal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PeerStorageRetrieval))))) | |||||
messageType :: Message -> MsgType Source #
Get the message type for a message.
A complete message envelope with type, payload, and optional extension.
Constructors
| Envelope | |
Fields
| |
Instances
| NFData Envelope Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message | |||||
| Generic Envelope Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message Associated Types
| |||||
| Show Envelope Source # | |||||
| Eq Envelope Source # | |||||
| type Rep Envelope Source # | |||||
Defined in Lightning.Protocol.BOLT1.Message type Rep Envelope = D1 ('MetaData "Envelope" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (C1 ('MetaCons "Envelope" 'PrefixI 'True) (S1 ('MetaSel ('Just "envType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MsgType) :*: (S1 ('MetaSel ('Just "envPayload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "envExtension") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe TlvStream))))) | |||||