bolt7

Routing gossip protocol, per BOLT #7 (docs.ppad.tech/bolt7).
git clone git://git.ppad.tech/bolt7.git
Log | Files | Refs | README | LICENSE

commit cc5b00a03554885286d7c845aa203e497cea9238
parent c6633cfbe6a81ac5fab87dbbbe10879ee04e5a37
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat, 10 Oct 2026 14:33:44 +0400

docs: disambiguate haddock type references

Diffstat:
Mlib/Lightning/Protocol/BOLT7/Codec.hs | 36++++++++++++++++++------------------
Mlib/Lightning/Protocol/BOLT7/Hash.hs | 16++++++++--------
Mlib/Lightning/Protocol/BOLT7/Types.hs | 44++++++++++++++++++++++----------------------
3 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/lib/Lightning/Protocol/BOLT7/Codec.hs b/lib/Lightning/Protocol/BOLT7/Codec.hs @@ -131,7 +131,7 @@ decode_message t bs = case t of -- channel_announcement ------------------------------------------------------- --- | Encode a 'ChannelAnnouncement' payload. Fails if the features exceed +-- | Encode a t'ChannelAnnouncement' payload. Fails if the features exceed -- 65535 bytes. encode_channel_announcement :: ChannelAnnouncement -> Either EncodeError BS.ByteString @@ -152,7 +152,7 @@ encode_channel_announcement m = do , BOLT1.encode_tlv_stream (ca_tlvs m) ] --- | Decode a 'ChannelAnnouncement' payload. +-- | Decode a t'ChannelAnnouncement' payload. decode_channel_announcement :: BS.ByteString -> Either DecodeError ChannelAnnouncement decode_channel_announcement b0 = do @@ -185,7 +185,7 @@ decode_channel_announcement b0 = do -- node_announcement ---------------------------------------------------------- --- | Encode a 'NodeAnnouncement' payload. Fails if the features or the +-- | Encode a t'NodeAnnouncement' payload. Fails if the features or the -- addresses exceed 65535 bytes, or if 'na_unknown_addresses' begins -- with a descriptor of a known type. encode_node_announcement @@ -219,7 +219,7 @@ encode_address a = case a of AddrDNS (Hostname h) p -> BS.cons 5 (BS.cons (fromIntegral (BS.length h)) (h <> BOLT1.encode_u16 p)) --- | Decode a 'NodeAnnouncement' payload. +-- | Decode a t'NodeAnnouncement' payload. -- -- Address descriptors are parsed up to the first one of an unknown -- type; it and the bytes after it are kept in 'na_unknown_addresses'. @@ -278,7 +278,7 @@ addresses = go [] -- channel_update ------------------------------------------------------------- --- | Encode a 'ChannelUpdate' payload. +-- | Encode a t'ChannelUpdate' payload. encode_channel_update :: ChannelUpdate -> BS.ByteString encode_channel_update m = let MessageFlags mf = cu_message_flags m @@ -297,7 +297,7 @@ encode_channel_update m = , BOLT1.encode_tlv_stream (cu_tlvs m) ] --- | Decode a 'ChannelUpdate' payload. +-- | Decode a t'ChannelUpdate' payload. -- -- @htlc_maximum_msat@ is always present; the @must_be_one@ bit of -- @message_flags@ is kept but not interpreted. @@ -332,7 +332,7 @@ decode_channel_update b0 = do -- announcement_signatures ---------------------------------------------------- --- | Encode an 'AnnouncementSignatures' payload. +-- | Encode an t'AnnouncementSignatures' payload. encode_announcement_signatures :: AnnouncementSignatures -> BS.ByteString encode_announcement_signatures m = mconcat [ BOLT1.un_channel_id (as_channel_id m) @@ -342,7 +342,7 @@ encode_announcement_signatures m = mconcat , BOLT1.encode_tlv_stream (as_tlvs m) ] --- | Decode an 'AnnouncementSignatures' payload. +-- | Decode an t'AnnouncementSignatures' payload. decode_announcement_signatures :: BS.ByteString -> Either DecodeError AnnouncementSignatures decode_announcement_signatures b0 = do @@ -355,7 +355,7 @@ decode_announcement_signatures b0 = do -- query_short_channel_ids ---------------------------------------------------- --- | Encode a 'QueryShortChannelIds' payload. Fails if the short channel +-- | Encode a t'QueryShortChannelIds' payload. Fails if the short channel -- ids exceed the u16 length limit (8191 of them), if the query flags -- don't number one per short channel id, or if 'qsci_tlvs' holds a -- record of type 1. @@ -374,7 +374,7 @@ encode_query_short_channel_ids m = do t <- merge [1] flags (qsci_tlvs m) pure (BOLT1.un_chain_hash (qsci_chain_hash m) <> ids <> t) --- | Decode a 'QueryShortChannelIds' payload. +-- | Decode a t'QueryShortChannelIds' payload. -- -- Fails on an unknown encoding type (including the deprecated zlib -- encoding), on @encoded_short_ids@ that isn't a whole number of short @@ -418,7 +418,7 @@ query_flags_value n v = case BS.uncons v of -- reply_short_channel_ids_end ------------------------------------------------ --- | Encode a 'ReplyShortChannelIdsEnd' payload. +-- | Encode a t'ReplyShortChannelIdsEnd' payload. encode_reply_short_channel_ids_end :: ReplyShortChannelIdsEnd -> BS.ByteString encode_reply_short_channel_ids_end m = mconcat @@ -427,7 +427,7 @@ encode_reply_short_channel_ids_end m = mconcat , BOLT1.encode_tlv_stream (rsce_tlvs m) ] --- | Decode a 'ReplyShortChannelIdsEnd' payload. +-- | Decode a t'ReplyShortChannelIdsEnd' payload. -- -- >>> decode_reply_short_channel_ids_end (BS.replicate 32 0 <> "\STX") -- Left DecodeInvalidBool @@ -441,7 +441,7 @@ decode_reply_short_channel_ids_end b0 = do -- query_channel_range -------------------------------------------------------- --- | Encode a 'QueryChannelRange' payload. Fails if 'qcr_tlvs' holds a +-- | Encode a t'QueryChannelRange' payload. Fails if 'qcr_tlvs' holds a -- record of type 1. encode_query_channel_range :: QueryChannelRange -> Either EncodeError BS.ByteString @@ -457,7 +457,7 @@ encode_query_channel_range m = do , t ] --- | Decode a 'QueryChannelRange' payload. +-- | Decode a t'QueryChannelRange' payload. decode_query_channel_range :: BS.ByteString -> Either DecodeError QueryChannelRange decode_query_channel_range b0 = do @@ -480,7 +480,7 @@ decode_query_channel_range b0 = do -- reply_channel_range -------------------------------------------------------- --- | Encode a 'ReplyChannelRange' payload. Fails if the short channel ids +-- | Encode a t'ReplyChannelRange' payload. Fails if the short channel ids -- exceed the u16 length limit (8191 of them), if the timestamps or -- checksums don't number one per short channel id, or if 'rcr_tlvs' -- holds a record of type 1 or 3. @@ -517,7 +517,7 @@ encode_reply_channel_range m = do where pair a b = BOLT1.encode_u32 a <> BOLT1.encode_u32 b --- | Decode a 'ReplyChannelRange' payload. +-- | Decode a t'ReplyChannelRange' payload. -- -- Fails on an unknown encoding type (including the deprecated zlib -- encoding), on @encoded_short_ids@ that isn't a whole number of short @@ -569,7 +569,7 @@ pairs t mk n r -- gossip_timestamp_filter ---------------------------------------------------- --- | Encode a 'GossipTimestampFilter' payload. +-- | Encode a t'GossipTimestampFilter' payload. encode_gossip_timestamp_filter :: GossipTimestampFilter -> BS.ByteString encode_gossip_timestamp_filter m = mconcat [ BOLT1.un_chain_hash (gtf_chain_hash m) @@ -578,7 +578,7 @@ encode_gossip_timestamp_filter m = mconcat , BOLT1.encode_tlv_stream (gtf_tlvs m) ] --- | Decode a 'GossipTimestampFilter' payload. +-- | Decode a t'GossipTimestampFilter' payload. decode_gossip_timestamp_filter :: BS.ByteString -> Either DecodeError GossipTimestampFilter decode_gossip_timestamp_filter b0 = do diff --git a/lib/Lightning/Protocol/BOLT7/Hash.hs b/lib/Lightning/Protocol/BOLT7/Hash.hs @@ -51,26 +51,26 @@ double_sha256 :: BS.ByteString -> BS.ByteString double_sha256 = SHA256.hash . SHA256.hash {-# INLINE double_sha256 #-} --- | The digest the four signatures of a 'ChannelAnnouncement' sign: the +-- | The digest the four signatures of a t'ChannelAnnouncement' sign: the -- double SHA-256 of its encoding from offset 256 (after the -- signatures) to the end. Fails as 'encode_channel_announcement' does. channel_announcement_hash :: ChannelAnnouncement -> Either EncodeError BS.ByteString channel_announcement_hash = fmap double_sha256 . announcement_signed --- | The digest the signature of a 'NodeAnnouncement' signs: the double +-- | The digest the signature of a t'NodeAnnouncement' signs: the double -- SHA-256 of its encoding after the signature. Fails as -- 'encode_node_announcement' does. node_announcement_hash :: NodeAnnouncement -> Either EncodeError BS.ByteString node_announcement_hash = fmap double_sha256 . node_signed --- | The digest the signature of a 'ChannelUpdate' signs: the double +-- | The digest the signature of a t'ChannelUpdate' signs: the double -- SHA-256 of its encoding after the signature. channel_update_hash :: ChannelUpdate -> BS.ByteString channel_update_hash = double_sha256 . update_signed --- | Verify the four signatures of a 'ChannelAnnouncement': both node +-- | Verify the four signatures of a t'ChannelAnnouncement': both node -- signatures and both bitcoin signatures, each over -- 'channel_announcement_hash' under the corresponding key. -- @@ -86,7 +86,7 @@ verify_channel_announcement m = case announcement_signed m of && verify d (ca_bitcoin_key_1 m) (ca_bitcoin_signature_1 m) && verify d (ca_bitcoin_key_2 m) (ca_bitcoin_signature_2 m) --- | Verify the signature of a 'NodeAnnouncement' under its node id. +-- | Verify the signature of a t'NodeAnnouncement' under its node id. -- -- As with libsecp256k1, the signature must be in low-s form. verify_node_announcement :: NodeAnnouncement -> Bool @@ -94,9 +94,9 @@ verify_node_announcement m = case node_signed m of Left _ -> False Right signed -> verify (SHA256.hash signed) (na_node_id m) (na_signature m) --- | Verify the signature of a 'ChannelUpdate' under the given node id. +-- | Verify the signature of a t'ChannelUpdate' under the given node id. -- --- The key is that of the channel's 'ChannelAnnouncement' selected by +-- The key is that of the channel's t'ChannelAnnouncement' selected by -- the update's direction: 'ca_node_id_1' for -- 'Lightning.Protocol.BOLT7.NodeOne', 'ca_node_id_2' for -- 'Lightning.Protocol.BOLT7.NodeTwo'. As with libsecp256k1, the @@ -114,7 +114,7 @@ verify d k s = (Just p, Just sig) -> Secp256k1.verify_ecdsa' Secp256k1.precompute d p sig _ -> False --- | The checksum of a 'ChannelUpdate', as used in the @checksums_tlv@ of +-- | The checksum of a t'ChannelUpdate', as used in the @checksums_tlv@ of -- @reply_channel_range@: the CRC-32C (RFC 3720) of the update without -- its signature and timestamp. Extension records are included. channel_update_checksum :: ChannelUpdate -> Word32 diff --git a/lib/Lightning/Protocol/BOLT7/Types.hs b/lib/Lightning/Protocol/BOLT7/Types.hs @@ -105,7 +105,7 @@ data Forwarding instance NFData Forwarding --- | The 'MessageFlags' an origin node sets: @must_be_one@ set, the given +-- | The t'MessageFlags' an origin node sets: @must_be_one@ set, the given -- @dont_forward@ bit, and no unassigned bits. -- -- >>> message_flags DontForward @@ -115,7 +115,7 @@ message_flags Forward = MessageFlags 0x01 message_flags DontForward = MessageFlags 0x03 {-# INLINE message_flags #-} --- | The @dont_forward@ bit of 'MessageFlags'. +-- | The @dont_forward@ bit of t'MessageFlags'. -- -- >>> message_flags_forwarding (MessageFlags 0x01) -- Forward @@ -159,7 +159,7 @@ data ChannelStatus instance NFData ChannelStatus --- | The 'ChannelFlags' for the given direction and status, with no +-- | The t'ChannelFlags' for the given direction and status, with no -- unassigned bits set. -- -- >>> channel_flags NodeTwo Disabled @@ -175,7 +175,7 @@ channel_flags d s = ChannelFlags (dir .|. sta) Disabled -> 0x02 {-# INLINE channel_flags #-} --- | The @direction@ bit of 'ChannelFlags'. +-- | The @direction@ bit of t'ChannelFlags'. -- -- >>> channel_flags_direction (ChannelFlags 0x05) -- NodeTwo @@ -185,7 +185,7 @@ channel_flags_direction (ChannelFlags w) | otherwise = NodeOne {-# INLINE channel_flags_direction #-} --- | The @disable@ bit of 'ChannelFlags'. +-- | The @disable@ bit of t'ChannelFlags'. -- -- >>> channel_flags_status (ChannelFlags 0x02) -- Disabled @@ -213,7 +213,7 @@ newtype Alias = Alias BS.ByteString instance NFData Alias --- | Construct an 'Alias' from exactly 32 bytes. +-- | Construct an t'Alias' from exactly 32 bytes. -- -- >>> alias "too short" -- Nothing @@ -223,7 +223,7 @@ alias bs | otherwise = Nothing {-# INLINE alias #-} --- | The bytes of an 'Alias'. +-- | The bytes of an t'Alias'. un_alias :: Alias -> BS.ByteString un_alias (Alias bs) = bs {-# INLINE un_alias #-} @@ -234,7 +234,7 @@ newtype IPv4Addr = IPv4Addr BS.ByteString instance NFData IPv4Addr --- | Construct an 'IPv4Addr' from exactly 4 bytes. +-- | Construct an t'IPv4Addr' from exactly 4 bytes. -- -- >>> ipv4_addr "\127\NUL\NUL\SOH" -- Just (IPv4Addr "\DEL\NUL\NUL\SOH") @@ -244,7 +244,7 @@ ipv4_addr bs | otherwise = Nothing {-# INLINE ipv4_addr #-} --- | The bytes of an 'IPv4Addr'. +-- | The bytes of an t'IPv4Addr'. un_ipv4_addr :: IPv4Addr -> BS.ByteString un_ipv4_addr (IPv4Addr bs) = bs {-# INLINE un_ipv4_addr #-} @@ -255,14 +255,14 @@ newtype IPv6Addr = IPv6Addr BS.ByteString instance NFData IPv6Addr --- | Construct an 'IPv6Addr' from exactly 16 bytes. +-- | Construct an t'IPv6Addr' from exactly 16 bytes. ipv6_addr :: BS.ByteString -> Maybe IPv6Addr ipv6_addr bs | BS.length bs == 16 = Just (IPv6Addr bs) | otherwise = Nothing {-# INLINE ipv6_addr #-} --- | The bytes of an 'IPv6Addr'. +-- | The bytes of an t'IPv6Addr'. un_ipv6_addr :: IPv6Addr -> BS.ByteString un_ipv6_addr (IPv6Addr bs) = bs {-# INLINE un_ipv6_addr #-} @@ -275,14 +275,14 @@ newtype TorV2Addr = TorV2Addr BS.ByteString instance NFData TorV2Addr --- | Construct a 'TorV2Addr' from exactly 12 bytes. +-- | Construct a t'TorV2Addr' from exactly 12 bytes. tor_v2_addr :: BS.ByteString -> Maybe TorV2Addr tor_v2_addr bs | BS.length bs == 12 = Just (TorV2Addr bs) | otherwise = Nothing {-# INLINE tor_v2_addr #-} --- | The bytes of a 'TorV2Addr'. +-- | The bytes of a t'TorV2Addr'. un_tor_v2_addr :: TorV2Addr -> BS.ByteString un_tor_v2_addr (TorV2Addr bs) = bs {-# INLINE un_tor_v2_addr #-} @@ -294,14 +294,14 @@ newtype TorV3Addr = TorV3Addr BS.ByteString instance NFData TorV3Addr --- | Construct a 'TorV3Addr' from exactly 35 bytes. +-- | Construct a t'TorV3Addr' from exactly 35 bytes. tor_v3_addr :: BS.ByteString -> Maybe TorV3Addr tor_v3_addr bs | BS.length bs == 35 = Just (TorV3Addr bs) | otherwise = Nothing {-# INLINE tor_v3_addr #-} --- | The bytes of a 'TorV3Addr'. +-- | The bytes of a t'TorV3Addr'. un_tor_v3_addr :: TorV3Addr -> BS.ByteString un_tor_v3_addr (TorV3Addr bs) = bs {-# INLINE un_tor_v3_addr #-} @@ -316,7 +316,7 @@ newtype Hostname = Hostname BS.ByteString instance NFData Hostname --- | Construct a 'Hostname' from at most 255 bytes. +-- | Construct a t'Hostname' from at most 255 bytes. -- -- >>> hostname "ln.example.com" -- Just (Hostname "ln.example.com") @@ -328,12 +328,12 @@ hostname bs | otherwise = Nothing {-# INLINE hostname #-} --- | The bytes of a 'Hostname'. +-- | The bytes of a t'Hostname'. un_hostname :: Hostname -> BS.ByteString un_hostname (Hostname bs) = bs {-# INLINE un_hostname #-} --- | Whether a 'Hostname' is non-empty and ASCII, as BOLT #7 requires. +-- | Whether a t'Hostname' is non-empty and ASCII, as BOLT #7 requires. -- -- >>> fmap is_ascii_hostname (hostname "caf\233") -- Just False @@ -385,7 +385,7 @@ newtype QueryFlags = QueryFlags Word64 instance NFData QueryFlags --- | The assigned bits of 'QueryFlags'. +-- | The assigned bits of t'QueryFlags'. data QueryFlag = WantChannelAnnouncement -- ^ bit 0 | WantChannelUpdate1 -- ^ bit 1: the @channel_update@ of node 1 @@ -396,7 +396,7 @@ data QueryFlag instance NFData QueryFlag --- | The 'QueryFlags' with exactly the given bits set. +-- | The t'QueryFlags' with exactly the given bits set. -- -- >>> query_flags [WantChannelAnnouncement, WantChannelUpdate2] -- QueryFlags 5 @@ -418,7 +418,7 @@ newtype QueryOption = QueryOption Word64 instance NFData QueryOption --- | The assigned bits of 'QueryOption'. +-- | The assigned bits of t'QueryOption'. data QueryOptionFlag = WantTimestamps -- ^ bit 0 | WantChecksums -- ^ bit 1 @@ -426,7 +426,7 @@ data QueryOptionFlag instance NFData QueryOptionFlag --- | The 'QueryOption' with exactly the given bits set. +-- | The t'QueryOption' with exactly the given bits set. -- -- >>> query_option [WantTimestamps, WantChecksums] -- QueryOption 3