bolt4

Onion routing protocol, per BOLT #4 (docs.ppad.tech/bolt4).
git clone git://git.ppad.tech/bolt4.git
Log | Files | Refs | README | LICENSE

commit 1694f71dc187752662c354d9f917b740037f5431
parent be4f803405adf5b837178103608efe6cd8ade840
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat, 10 Oct 2026 15:02:38 +0400

docs: disambiguate haddock references to types

Diffstat:
Mlib/Lightning/Protocol/BOLT4/Codec.hs | 10+++++-----
Mlib/Lightning/Protocol/BOLT4/Prim.hs | 8++++----
Mlib/Lightning/Protocol/BOLT4/Types.hs | 26+++++++++++++-------------
3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/lib/Lightning/Protocol/BOLT4/Codec.hs b/lib/Lightning/Protocol/BOLT4/Codec.hs @@ -29,7 +29,7 @@ import qualified Lightning.Protocol.BOLT9 as BOLT9 -- onion packets -------------------------------------------------------------- --- | Encode an 'OnionPacket' (1366 bytes). +-- | Encode an t'OnionPacket' (1366 bytes). -- -- >>> let Just pk = BOLT1.point (BS.cons 0x02 (BS.replicate 32 0x01)) -- >>> let Just hp = hop_payloads (BS.replicate 1300 0) @@ -40,7 +40,7 @@ encode_onion_packet :: OnionPacket -> BS.ByteString encode_onion_packet (OnionPacket v k hp mac) = BS.concat [BS.singleton v, BOLT1.un_point k, un_hop_payloads hp, un_hmac32 mac] --- | Decode an 'OnionPacket' from exactly 1366 bytes. The public key must +-- | Decode an t'OnionPacket' from exactly 1366 bytes. The public key must -- carry a compressed-encoding prefix; the version byte is not checked -- (see 'Lightning.Protocol.BOLT4.process'). -- @@ -114,7 +114,7 @@ decode_tu_msat v = BOLT1.decode_tu64 v >>= BOLT1.milli_satoshi hop_payload_types :: [Word64] hop_payload_types = [2, 4, 6, 8, 10, 12, 16, 18] --- | Encode a 'HopPayload' as a @payload@ TLV stream (without its length +-- | Encode a t'HopPayload' as a @payload@ TLV stream (without its length -- prefix). Fails if 'hp_extra' has a record of a known type. -- -- >>> let hp = empty_hop_payload { hp_outgoing_cltv_value = Just 144 } @@ -169,7 +169,7 @@ decode_payment_data v = do blinded_hop_data_types :: [Word64] blinded_hop_data_types = [1, 2, 4, 6, 8, 10, 12, 14] --- | Encode 'BlindedHopData' as an @encrypted_data_tlv@ stream. Fails if +-- | Encode t'BlindedHopData' as an @encrypted_data_tlv@ stream. Fails if -- 'bhd_extra' has a record of a known type. encode_blinded_hop_data :: BlindedHopData -> Either EncodeError BS.ByteString encode_blinded_hop_data d = @@ -226,7 +226,7 @@ decode_payment_constraints v = do -- failure messages ----------------------------------------------------------- --- | Encode a 'FailureMessage': the failure code, its data and the TLV +-- | Encode a t'FailureMessage': the failure code, its data and the TLV -- stream. Fails if a @channel_update@ exceeds 65535 bytes. -- -- >>> let tlvs = BOLT1.empty_tlv_stream diff --git a/lib/Lightning/Protocol/BOLT4/Prim.hs b/lib/Lightning/Protocol/BOLT4/Prim.hs @@ -78,7 +78,7 @@ instance Show SecretKey where instance NFData SecretKey where rnf (SecretKey k p q) = rnf k `seq` p `seq` rnf q --- | Construct a 'SecretKey' from exactly 32 big-endian bytes encoding an +-- | Construct a t'SecretKey' from exactly 32 big-endian bytes encoding an -- integer in [1, n - 1], where n is the secp256k1 group order. -- -- >>> secret_key (BS.replicate 32 0x41) @@ -95,7 +95,7 @@ secret_key bs pt <- to_point pub pure $! SecretKey bs pub pt --- | The public key of a 'SecretKey'. +-- | The public key of a t'SecretKey'. -- -- >>> let Just sk = secret_key (BS.replicate 32 0x41) -- >>> BS.length (BOLT1.un_point (public_key sk)) @@ -131,7 +131,7 @@ instance Show SharedSecret where instance NFData SharedSecret where rnf (SharedSecret bs) = rnf bs --- | Construct a 'SharedSecret' from exactly 32 bytes (e.g. to restore one +-- | Construct a t'SharedSecret' from exactly 32 bytes (e.g. to restore one -- that was stored with 'un_shared_secret'). -- -- >>> let Just ss = shared_secret (BS.replicate 32 0x01) @@ -145,7 +145,7 @@ shared_secret bs | otherwise = Nothing {-# INLINE shared_secret #-} --- | The bytes of a 'SharedSecret'. +-- | The bytes of a t'SharedSecret'. un_shared_secret :: SharedSecret -> BS.ByteString un_shared_secret (SharedSecret bs) = bs {-# INLINE un_shared_secret #-} diff --git a/lib/Lightning/Protocol/BOLT4/Types.hs b/lib/Lightning/Protocol/BOLT4/Types.hs @@ -85,7 +85,7 @@ newtype HopPayloads = HopPayloads BS.ByteString instance NFData HopPayloads --- | Construct 'HopPayloads' from exactly 1300 bytes. +-- | Construct t'HopPayloads' from exactly 1300 bytes. -- -- >>> let Just hp = hop_payloads (BS.replicate 1300 0) -- >>> BS.length (un_hop_payloads hp) @@ -98,7 +98,7 @@ hop_payloads bs | otherwise = Nothing {-# INLINE hop_payloads #-} --- | The bytes of 'HopPayloads'. +-- | The bytes of t'HopPayloads'. un_hop_payloads :: HopPayloads -> BS.ByteString un_hop_payloads (HopPayloads bs) = bs {-# INLINE un_hop_payloads #-} @@ -109,7 +109,7 @@ newtype Hmac32 = Hmac32 BS.ByteString instance NFData Hmac32 --- | Construct an 'Hmac32' from exactly 32 bytes. +-- | Construct an t'Hmac32' from exactly 32 bytes. -- -- >>> fmap (BS.length . un_hmac32) (hmac32 (BS.replicate 32 0)) -- Just 32 @@ -121,7 +121,7 @@ hmac32 bs | otherwise = Nothing {-# INLINE hmac32 #-} --- | The bytes of an 'Hmac32'. +-- | The bytes of an t'Hmac32'. un_hmac32 :: Hmac32 -> BS.ByteString un_hmac32 (Hmac32 bs) = bs {-# INLINE un_hmac32 #-} @@ -157,7 +157,7 @@ data HopPayload = HopPayload instance NFData HopPayload --- | The empty 'HopPayload', to be updated with record syntax. +-- | The empty t'HopPayload', to be updated with record syntax. -- -- >>> let Just amt = BOLT1.milli_satoshi 1000 -- >>> let hp = empty_hop_payload { hp_amt_to_forward = Just amt } @@ -192,7 +192,7 @@ instance Show PaymentSecret where instance NFData PaymentSecret where rnf (PaymentSecret bs) = rnf bs --- | Construct a 'PaymentSecret' from exactly 32 bytes. +-- | Construct a t'PaymentSecret' from exactly 32 bytes. -- -- >>> payment_secret (BS.replicate 32 0x01) -- Just (PaymentSecret <redacted>) @@ -204,7 +204,7 @@ payment_secret bs | otherwise = Nothing {-# INLINE payment_secret #-} --- | The bytes of a 'PaymentSecret'. +-- | The bytes of a t'PaymentSecret'. un_payment_secret :: PaymentSecret -> BS.ByteString un_payment_secret (PaymentSecret bs) = bs {-# INLINE un_payment_secret #-} @@ -236,7 +236,7 @@ instance NFData BlindedHop -- | The @encrypted_data_tlv@ stream carried, encrypted, in a hop's -- @encrypted_recipient_data@. -- --- 'bhd_extra' plays the same role as 'hp_extra' in 'HopPayload'. +-- 'bhd_extra' plays the same role as 'hp_extra' in t'HopPayload'. data BlindedHopData = BlindedHopData { bhd_padding :: !(Maybe BS.ByteString) -- ^ type 1: @padding@ @@ -260,7 +260,7 @@ data BlindedHopData = BlindedHopData instance NFData BlindedHopData --- | The empty 'BlindedHopData', to be updated with record syntax. +-- | The empty t'BlindedHopData', to be updated with record syntax. -- -- >>> let bhd = empty_blinded_hop_data { bhd_path_id = Just "path id" } -- >>> encode_blinded_hop_data bhd @@ -270,7 +270,7 @@ empty_blinded_hop_data = BlindedHopData Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing BOLT1.empty_tlv_stream --- | The @payment_relay@ record of 'BlindedHopData'. +-- | The @payment_relay@ record of t'BlindedHopData'. data PaymentRelay = PaymentRelay { pr_cltv_expiry_delta :: {-# UNPACK #-} !Word16 , pr_fee_proportional_millionths :: {-# UNPACK #-} !Word32 @@ -279,7 +279,7 @@ data PaymentRelay = PaymentRelay instance NFData PaymentRelay --- | The @payment_constraints@ record of 'BlindedHopData'. +-- | The @payment_constraints@ record of t'BlindedHopData'. data PaymentConstraints = PaymentConstraints { pc_max_cltv_expiry :: {-# UNPACK #-} !Word32 , pc_htlc_minimum_msat :: !BOLT1.MilliSatoshi @@ -371,7 +371,7 @@ newtype OnionHash = OnionHash BS.ByteString instance NFData OnionHash --- | Construct an 'OnionHash' from exactly 32 bytes. +-- | Construct an t'OnionHash' from exactly 32 bytes. -- -- >>> fmap (BS.length . un_onion_hash) (onion_hash (BS.replicate 32 0)) -- Just 32 @@ -381,7 +381,7 @@ onion_hash bs | otherwise = Nothing {-# INLINE onion_hash #-} --- | The bytes of an 'OnionHash'. +-- | The bytes of an t'OnionHash'. un_onion_hash :: OnionHash -> BS.ByteString un_onion_hash (OnionHash bs) = bs {-# INLINE un_onion_hash #-}