bolt1

Base Lightning protocol, per BOLT #1 (docs.ppad.tech/bolt1).
git clone git://git.ppad.tech/bolt1.git
Log | Files | Refs | README | LICENSE

BOLT1.hs (2562B)


      1 {-# OPTIONS_HADDOCK prune #-}
      2 
      3 -- |
      4 -- Module: Lightning.Protocol.BOLT1
      5 -- Copyright: (c) 2025 Jared Tobin
      6 -- License: MIT
      7 -- Maintainer: Jared Tobin <jared@ppad.tech>
      8 --
      9 -- Base protocol for the Lightning Network, per
     10 -- [BOLT #1](https://github.com/lightning/bolts/blob/master/01-messaging.md).
     11 
     12 module Lightning.Protocol.BOLT1 (
     13   -- * Message types
     14     Message(..)
     15   , MsgType(
     16       MsgInit
     17     , MsgError
     18     , MsgPing
     19     , MsgPong
     20     , MsgWarning
     21     , MsgPeerStorage
     22     , MsgPeerStorageRet
     23     )
     24   , msgUnknown
     25   , msgTypeWord
     26 
     27   -- * Channel identifiers
     28   , ChannelId(..)
     29   , channelId
     30   , unChannelId
     31   , allChannels
     32 
     33   -- * Signatures and keys
     34   , Signature(..)
     35   , signature
     36   , unSignature
     37   , Point(..)
     38   , point
     39   , unPoint
     40 
     41   -- * Payment types
     42   , PaymentHash(..)
     43   , paymentHash
     44   , unPaymentHash
     45   , PaymentPreimage(..)
     46   , paymentPreimage
     47   , unPaymentPreimage
     48 
     49   -- * Per-commitment secret
     50   , PerCommitmentSecret(..)
     51   , perCommitmentSecret
     52   , unPerCommitmentSecret
     53 
     54   -- * Short channel identifier
     55   , ShortChannelId(..)
     56   , shortChannelId
     57   , scidWord64
     58   , scidBlockHeight
     59   , scidTxIndex
     60   , scidOutputIndex
     61 
     62   -- * Amounts
     63   , Satoshi(..)
     64   , MilliSatoshi(..)
     65   , satToMsat
     66   , msatToSat
     67 
     68   -- ** Setup messages
     69   , Init(..)
     70   , Error(..)
     71   , Warning(..)
     72 
     73   -- ** Control messages
     74   , Ping(..)
     75   , Pong(..)
     76 
     77   -- ** Peer storage
     78   , PeerStorage(..)
     79   , PeerStorageRetrieval(..)
     80 
     81   -- * TLV
     82   , TlvRecord(..)
     83   , TlvStream
     84   , unTlvStream
     85   , tlvStream
     86   , unsafeTlvStream
     87   , TlvError(..)
     88   , encodeTlvStream
     89   , decodeTlvStream
     90   , decodeTlvStreamWith
     91   , decodeTlvStreamRaw
     92 
     93   -- ** Init TLVs
     94   , InitTlv(..)
     95   , ChainHash(..)
     96   , chainHash
     97   , unChainHash
     98 
     99   -- * Message envelope
    100   , Envelope
    101   , envelope
    102   , envType
    103   , envPayload
    104   , envExtension
    105 
    106   -- * Encoding
    107   , EncodeError(..)
    108   , encodeMessage
    109   , encodeEnvelope
    110 
    111   -- * Decoding
    112   , DecodeError(..)
    113   , decodeMessage
    114   , decodeEnvelope
    115   , decodeEnvelopeWith
    116 
    117   -- * Primitive encoding
    118   , encodeU16
    119   , encodeU32
    120   , encodeU64
    121   , encodeS8
    122   , encodeS16
    123   , encodeS32
    124   , encodeS64
    125   , encodeTu16
    126   , encodeTu32
    127   , encodeTu64
    128   , encodeMinSigned
    129   , encodeBigSize
    130 
    131   -- * Primitive decoding
    132   , decodeU16
    133   , decodeU32
    134   , decodeU64
    135   , decodeS8
    136   , decodeS16
    137   , decodeS32
    138   , decodeS64
    139   , decodeTu16
    140   , decodeTu32
    141   , decodeTu64
    142   , decodeMinSigned
    143   , decodeBigSize
    144   ) where
    145 
    146 -- Re-export from sub-modules
    147 import Lightning.Protocol.BOLT1.Prim
    148 import Lightning.Protocol.BOLT1.TLV
    149 import Lightning.Protocol.BOLT1.Message
    150 import Lightning.Protocol.BOLT1.Codec