| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Lightning.Protocol.BOLT7.Codec
Description
Encoding and decoding for BOLT #7 gossip messages.
Synopsis
- data EncodeError = EncodeLengthOverflow
- data DecodeError
- encodeChannelAnnouncement :: ChannelAnnouncement -> ByteString
- decodeChannelAnnouncement :: ByteString -> Either DecodeError (ChannelAnnouncement, ByteString)
- encodeNodeAnnouncement :: NodeAnnouncement -> Either EncodeError ByteString
- decodeNodeAnnouncement :: ByteString -> Either DecodeError (NodeAnnouncement, ByteString)
- encodeChannelUpdate :: ChannelUpdate -> ByteString
- decodeChannelUpdate :: ByteString -> Either DecodeError (ChannelUpdate, ByteString)
- encodeAnnouncementSignatures :: AnnouncementSignatures -> ByteString
- decodeAnnouncementSignatures :: ByteString -> Either DecodeError (AnnouncementSignatures, ByteString)
- encodeQueryShortChannelIds :: QueryShortChannelIds -> Either EncodeError ByteString
- decodeQueryShortChannelIds :: ByteString -> Either DecodeError (QueryShortChannelIds, ByteString)
- encodeReplyShortChannelIdsEnd :: ReplyShortChannelIdsEnd -> ByteString
- decodeReplyShortChannelIdsEnd :: ByteString -> Either DecodeError (ReplyShortChannelIdsEnd, ByteString)
- encodeQueryChannelRange :: QueryChannelRange -> ByteString
- decodeQueryChannelRange :: ByteString -> Either DecodeError (QueryChannelRange, ByteString)
- encodeReplyChannelRange :: ReplyChannelRange -> Either EncodeError ByteString
- decodeReplyChannelRange :: ByteString -> Either DecodeError (ReplyChannelRange, ByteString)
- encodeGossipTimestampFilter :: GossipTimestampFilter -> ByteString
- decodeGossipTimestampFilter :: ByteString -> Either DecodeError (GossipTimestampFilter, ByteString)
- encodeShortChannelIdList :: [ShortChannelId] -> ByteString
- decodeShortChannelIdList :: ByteString -> Either DecodeError [ShortChannelId]
Error types
data EncodeError Source #
Encoding errors.
Constructors
| EncodeLengthOverflow | Field too large for u16 length prefix |
Instances
| NFData EncodeError Source # | |||||
Defined in Lightning.Protocol.BOLT7.Codec Methods rnf :: EncodeError -> () # | |||||
| Generic EncodeError Source # | |||||
Defined in Lightning.Protocol.BOLT7.Codec Associated Types
| |||||
| Show EncodeError Source # | |||||
Defined in Lightning.Protocol.BOLT7.Codec Methods showsPrec :: Int -> EncodeError -> ShowS # show :: EncodeError -> String # showList :: [EncodeError] -> ShowS # | |||||
| Eq EncodeError Source # | |||||
Defined in Lightning.Protocol.BOLT7.Codec | |||||
| type Rep EncodeError Source # | |||||
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
| NFData DecodeError Source # | |||||
Defined in Lightning.Protocol.BOLT7.Codec Methods rnf :: DecodeError -> () # | |||||
| Generic DecodeError Source # | |||||
Defined in Lightning.Protocol.BOLT7.Codec Associated Types
| |||||
| Show DecodeError Source # | |||||
Defined in Lightning.Protocol.BOLT7.Codec Methods showsPrec :: Int -> DecodeError -> ShowS # show :: DecodeError -> String # showList :: [DecodeError] -> ShowS # | |||||
| Eq DecodeError Source # | |||||
Defined in Lightning.Protocol.BOLT7.Codec | |||||
| type Rep DecodeError Source # | |||||
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.
decodeChannelAnnouncement :: ByteString -> Either DecodeError (ChannelAnnouncement, ByteString) Source #
Decode channel_announcement message.
Node announcement
encodeNodeAnnouncement :: NodeAnnouncement -> Either EncodeError ByteString Source #
Encode node_announcement message.
decodeNodeAnnouncement :: ByteString -> Either DecodeError (NodeAnnouncement, ByteString) Source #
Decode node_announcement message.
Channel update
encodeChannelUpdate :: ChannelUpdate -> ByteString Source #
Encode channel_update message.
decodeChannelUpdate :: ByteString -> Either DecodeError (ChannelUpdate, ByteString) Source #
Decode channel_update message.
Announcement signatures
encodeAnnouncementSignatures :: AnnouncementSignatures -> ByteString Source #
Encode announcement_signatures message.
decodeAnnouncementSignatures :: ByteString -> Either DecodeError (AnnouncementSignatures, ByteString) Source #
Decode announcement_signatures message.
Query messages
encodeQueryShortChannelIds :: QueryShortChannelIds -> Either EncodeError ByteString Source #
Encode query_short_channel_ids message.
decodeQueryShortChannelIds :: ByteString -> Either DecodeError (QueryShortChannelIds, ByteString) Source #
Decode query_short_channel_ids message.
encodeReplyShortChannelIdsEnd :: ReplyShortChannelIdsEnd -> ByteString Source #
Encode reply_short_channel_ids_end message.
decodeReplyShortChannelIdsEnd :: ByteString -> Either DecodeError (ReplyShortChannelIdsEnd, ByteString) Source #
Decode reply_short_channel_ids_end message.
encodeQueryChannelRange :: QueryChannelRange -> ByteString Source #
Encode query_channel_range message.
decodeQueryChannelRange :: ByteString -> Either DecodeError (QueryChannelRange, ByteString) Source #
Decode query_channel_range message.
encodeReplyChannelRange :: ReplyChannelRange -> Either EncodeError ByteString Source #
Encode reply_channel_range message.
decodeReplyChannelRange :: ByteString -> Either DecodeError (ReplyChannelRange, ByteString) Source #
Decode reply_channel_range message.
encodeGossipTimestampFilter :: GossipTimestampFilter -> ByteString Source #
Encode gossip_timestamp_filter message.
decodeGossipTimestampFilter :: ByteString -> Either DecodeError (GossipTimestampFilter, ByteString) Source #
Decode 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.