ppad-bolt1-0.0.1: Base protocol per BOLT #1
Copyright(c) 2025 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellNone
LanguageHaskell2010

Lightning.Protocol.BOLT1.Message

Description

Message types for BOLT #1.

Synopsis

Message types

data MsgType Source #

BOLT #1 message type codes.

Instances

Instances details
NFData MsgType Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: MsgType -> () #

Generic MsgType Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep MsgType 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

type Rep MsgType = D1 ('MetaData "MsgType" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (((C1 ('MetaCons "MsgInit" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MsgError" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MsgPing" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MsgPong" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "MsgWarning" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MsgPeerStorage" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MsgPeerStorageRet" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MsgUnknown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word16)))))

Methods

from :: MsgType -> Rep MsgType x #

to :: Rep MsgType x -> MsgType #

Show MsgType Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Eq MsgType Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

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

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

type Rep MsgType Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

type Rep MsgType = D1 ('MetaData "MsgType" "Lightning.Protocol.BOLT1.Message" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'False) (((C1 ('MetaCons "MsgInit" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MsgError" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MsgPing" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MsgPong" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "MsgWarning" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MsgPeerStorage" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MsgPeerStorageRet" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MsgUnknown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word16)))))

msgUnknown :: Word16 -> MsgType Source #

Smart constructor for unknown message types.

Returns the appropriate known constructor for known type codes (16, 17, 18, 19, 1, 7, 9) and only uses MsgUnknown for truly unknown codes.

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

data ChannelId Source #

A 32-byte channel identifier.

Instances

Instances details
NFData ChannelId Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Prim

Methods

rnf :: ChannelId -> () #

Generic ChannelId Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Prim

Associated Types

type Rep ChannelId 
Instance details

Defined in Lightning.Protocol.BOLT1.Prim

type Rep ChannelId = D1 ('MetaData "ChannelId" "Lightning.Protocol.BOLT1.Prim" "ppad-bolt1-0.0.1-3AI6PDE70OhJud7vB7rIZR" 'True) (C1 ('MetaCons "ChannelId" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))
Show ChannelId Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Prim

Eq ChannelId Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Prim

Ord ChannelId Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Prim

type Rep ChannelId Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Prim

type Rep ChannelId = D1 ('MetaData "ChannelId" "Lightning.Protocol.BOLT1.Prim" "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.

unChannelId :: ChannelId -> ByteString Source #

Extract the raw bytes from a ChannelId.

allChannels :: ChannelId Source #

The all-zeros channel ID (connection-level errors).

Setup messages

data Init Source #

The init message (type 16).

Instances

Instances details
NFData Init Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: Init -> () #

Generic Init Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep Init 
Instance details

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]))))

Methods

from :: Init -> Rep Init x #

to :: Rep Init x -> Init #

Show Init Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

showsPrec :: Int -> Init -> ShowS #

show :: Init -> String #

showList :: [Init] -> ShowS #

Eq Init Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

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

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

type Rep Init Source # 
Instance details

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]))))

data Error Source #

The error message (type 17).

Constructors

Error 

Instances

Instances details
NFData Error Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: Error -> () #

Generic Error Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep Error 
Instance details

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)))

Methods

from :: Error -> Rep Error x #

to :: Rep Error x -> Error #

Show Error Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

Eq Error Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

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

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

type Rep Error Source # 
Instance details

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)))

data Warning Source #

The warning message (type 1).

Instances

Instances details
NFData Warning Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: Warning -> () #

Generic Warning Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep Warning 
Instance details

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)))

Methods

from :: Warning -> Rep Warning x #

to :: Rep Warning x -> Warning #

Show Warning Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Eq Warning Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

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

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

type Rep Warning Source # 
Instance details

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

data Ping Source #

The ping message (type 18).

Constructors

Ping 

Instances

Instances details
NFData Ping Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: Ping -> () #

Generic Ping Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep Ping 
Instance details

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)))

Methods

from :: Ping -> Rep Ping x #

to :: Rep Ping x -> Ping #

Show Ping Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

showsPrec :: Int -> Ping -> ShowS #

show :: Ping -> String #

showList :: [Ping] -> ShowS #

Eq Ping Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

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

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

type Rep Ping Source # 
Instance details

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)))

data Pong Source #

The pong message (type 19).

Constructors

Pong 

Instances

Instances details
NFData Pong Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: Pong -> () #

Generic Pong Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep Pong 
Instance details

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)))

Methods

from :: Pong -> Rep Pong x #

to :: Rep Pong x -> Pong #

Show Pong Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

showsPrec :: Int -> Pong -> ShowS #

show :: Pong -> String #

showList :: [Pong] -> ShowS #

Eq Pong Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

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

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

type Rep Pong Source # 
Instance details

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 

Instances

Instances details
NFData PeerStorage Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: PeerStorage -> () #

Generic PeerStorage Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep PeerStorage 
Instance details

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)))
Show PeerStorage Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Eq PeerStorage Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

type Rep PeerStorage Source # 
Instance details

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).

Instances

Instances details
NFData PeerStorageRetrieval Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: PeerStorageRetrieval -> () #

Generic PeerStorageRetrieval Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep PeerStorageRetrieval 
Instance details

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)))
Show PeerStorageRetrieval Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Eq PeerStorageRetrieval Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

type Rep PeerStorageRetrieval Source # 
Instance details

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

data Message Source #

All BOLT #1 messages.

Instances

Instances details
NFData Message Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: Message -> () #

Generic Message Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

from :: Message -> Rep Message x #

to :: Rep Message x -> Message #

Show Message Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Eq Message Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

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

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

type Rep Message Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

messageType :: Message -> MsgType Source #

Get the message type for a message.

data Envelope Source #

A complete message envelope with type, payload, and optional extension.

Instances

Instances details
NFData Envelope Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Methods

rnf :: Envelope -> () #

Generic Envelope Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Associated Types

type Rep Envelope 
Instance details

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)))))

Methods

from :: Envelope -> Rep Envelope x #

to :: Rep Envelope x -> Envelope #

Show Envelope Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

Eq Envelope Source # 
Instance details

Defined in Lightning.Protocol.BOLT1.Message

type Rep Envelope Source # 
Instance details

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)))))

envelope :: Message -> Maybe TlvStream -> Envelope Source #

Construct an Envelope from a Message and optional extension TLV stream. The envType is derived automatically from the Message.