ppad-bolt7-0.0.1: Routing gossip per BOLT #7
Copyright(c) 2025 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Lightning.Protocol.BOLT7.Codec

Description

Encoding and decoding for BOLT #7 gossip messages.

Synopsis

Error types

data EncodeError Source #

Encoding errors.

Constructors

EncodeLengthOverflow

Field too large for u16 length prefix

Instances

Instances details
NFData EncodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

Methods

rnf :: EncodeError -> () #

Generic EncodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

Associated Types

type Rep EncodeError 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

type Rep EncodeError = D1 ('MetaData "EncodeError" "Lightning.Protocol.BOLT7.Codec" "ppad-bolt7-0.0.1-9AmpjHUse7iEtxOkiaMheY" 'False) (C1 ('MetaCons "EncodeLengthOverflow" 'PrefixI 'False) (U1 :: Type -> Type))
Show EncodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

Eq EncodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

type Rep EncodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

type Rep EncodeError = D1 ('MetaData "EncodeError" "Lightning.Protocol.BOLT7.Codec" "ppad-bolt7-0.0.1-9AmpjHUse7iEtxOkiaMheY" 'False) (C1 ('MetaCons "EncodeLengthOverflow" 'PrefixI 'False) (U1 :: Type -> Type))

data DecodeError Source #

Decoding errors.

Constructors

DecodeInsufficientBytes

Not enough bytes

DecodeInvalidSignature

Invalid signature field

DecodeInvalidChainHash

Invalid chain hash field

DecodeInvalidShortChannelId

Invalid short channel ID field

DecodeInvalidChannelId

Invalid channel ID field

DecodeInvalidNodeId

Invalid node ID field

DecodeInvalidPoint

Invalid point field

DecodeInvalidRgbColor

Invalid RGB color field

DecodeInvalidAlias

Invalid alias field

DecodeInvalidAddress

Invalid address encoding

DecodeTlvError

TLV decoding error

Instances

Instances details
NFData DecodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

Methods

rnf :: DecodeError -> () #

Generic DecodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

Associated Types

type Rep DecodeError 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

type Rep DecodeError = D1 ('MetaData "DecodeError" "Lightning.Protocol.BOLT7.Codec" "ppad-bolt7-0.0.1-9AmpjHUse7iEtxOkiaMheY" 'False) (((C1 ('MetaCons "DecodeInsufficientBytes" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeInvalidSignature" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DecodeInvalidChainHash" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DecodeInvalidShortChannelId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeInvalidChannelId" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "DecodeInvalidNodeId" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DecodeInvalidPoint" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeInvalidRgbColor" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "DecodeInvalidAlias" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DecodeInvalidAddress" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeTlvError" 'PrefixI 'False) (U1 :: Type -> Type)))))
Show DecodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

Eq DecodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

type Rep DecodeError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Codec

type Rep DecodeError = D1 ('MetaData "DecodeError" "Lightning.Protocol.BOLT7.Codec" "ppad-bolt7-0.0.1-9AmpjHUse7iEtxOkiaMheY" 'False) (((C1 ('MetaCons "DecodeInsufficientBytes" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeInvalidSignature" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DecodeInvalidChainHash" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DecodeInvalidShortChannelId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeInvalidChannelId" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "DecodeInvalidNodeId" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DecodeInvalidPoint" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeInvalidRgbColor" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "DecodeInvalidAlias" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DecodeInvalidAddress" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeTlvError" 'PrefixI 'False) (U1 :: Type -> Type)))))

Channel announcement

encodeChannelAnnouncement :: ChannelAnnouncement -> ByteString Source #

Encode channel_announcement message.

Node announcement

Channel update

encodeChannelUpdate :: ChannelUpdate -> ByteString Source #

Encode channel_update message.

Announcement signatures

encodeAnnouncementSignatures :: AnnouncementSignatures -> ByteString Source #

Encode announcement_signatures message.

Query messages

encodeReplyShortChannelIdsEnd :: ReplyShortChannelIdsEnd -> ByteString Source #

Encode reply_short_channel_ids_end message.

encodeQueryChannelRange :: QueryChannelRange -> ByteString Source #

Encode query_channel_range message.

encodeGossipTimestampFilter :: GossipTimestampFilter -> ByteString Source #

Encode gossip_timestamp_filter message.

Short channel ID encoding

encodeShortChannelIdList :: [ShortChannelId] -> ByteString Source #

Encode a list of short channel IDs as concatenated 8-byte values.

This produces encoded_short_ids data with encoding type 0 (uncompressed). The first byte is the encoding type (0), followed by the concatenated SCIDs.

Note: This does NOT sort the SCIDs. The caller should ensure they are in ascending order if that's required by the protocol context.

decodeShortChannelIdList :: ByteString -> Either DecodeError [ShortChannelId] Source #

Decode a list of short channel IDs from encoded_short_ids data.

Supports encoding type 0 (uncompressed). Other encoding types will fail.