BOLT1.hs (3225B)
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 -- The base protocol of the Lightning Network, per 10 -- [BOLT #1](https://github.com/lightning/bolts/blob/master/01-messaging.md): 11 -- fundamental types and their encodings, the TLV format, and the 12 -- @init@, @error@, @warning@, @ping@, @pong@, @peer_storage@ and 13 -- @peer_storage_retrieval@ messages. 14 -- 15 -- The fundamental types and TLV machinery here are shared by the other 16 -- ppad BOLT libraries. 17 18 module Lightning.Protocol.BOLT1 ( 19 -- * Messages 20 Message(..) 21 , message_type 22 , Init(..) 23 , Error(..) 24 , Warning(..) 25 , Ping(..) 26 , Pong(..) 27 , ping_response 28 , PeerStorage(..) 29 , PeerStorageRetrieval(..) 30 31 -- * Encoding and decoding messages 32 , encode_message 33 , decode_message 34 , encode_envelope 35 , decode_envelope 36 , EncodeError(..) 37 , DecodeError(..) 38 39 -- ** Payloads 40 , encode_init 41 , decode_init 42 , encode_error 43 , decode_error 44 , encode_warning 45 , decode_warning 46 , encode_ping 47 , decode_ping 48 , encode_pong 49 , decode_pong 50 , encode_peer_storage 51 , decode_peer_storage 52 , encode_peer_storage_retrieval 53 , decode_peer_storage_retrieval 54 55 -- * TLV 56 , TlvRecord(..) 57 , TlvStream 58 , tlv_stream 59 , un_tlv_stream 60 , empty_tlv_stream 61 , lookup_tlv 62 , filter_tlv_stream 63 , encode_tlv_stream 64 , decode_tlv_stream 65 , TlvError(..) 66 67 -- * Fundamental types 68 , ChainHash 69 , chain_hash 70 , un_chain_hash 71 , ChannelId 72 , channel_id 73 , un_channel_id 74 , all_channels 75 , Signature 76 , signature 77 , un_signature 78 , Point 79 , point 80 , un_point 81 , PaymentHash 82 , payment_hash 83 , un_payment_hash 84 , PaymentPreimage 85 , payment_preimage 86 , un_payment_preimage 87 , PerCommitmentSecret 88 , per_commitment_secret 89 , un_per_commitment_secret 90 , ShortChannelId(..) 91 , short_channel_id 92 , scid_block_height 93 , scid_tx_index 94 , scid_output_index 95 96 -- ** Amounts 97 , Satoshi 98 , satoshi 99 , un_satoshi 100 , max_satoshi 101 , MilliSatoshi 102 , milli_satoshi 103 , un_milli_satoshi 104 , max_milli_satoshi 105 , sat_to_msat 106 , msat_to_sat 107 , add_sat 108 , sub_sat 109 , add_msat 110 , sub_msat 111 112 -- * Primitive encodings 113 -- | Decoders return the decoded value and the remaining input, except 114 -- for the truncated integers, which occupy their whole input. 115 , encode_u16 116 , encode_u32 117 , encode_u64 118 , decode_u16 119 , decode_u32 120 , decode_u64 121 , encode_s8 122 , encode_s16 123 , encode_s32 124 , encode_s64 125 , decode_s8 126 , decode_s16 127 , decode_s32 128 , decode_s64 129 , encode_tu16 130 , encode_tu32 131 , encode_tu64 132 , decode_tu16 133 , decode_tu32 134 , decode_tu64 135 , encode_bigsize 136 , decode_bigsize 137 , encode_u16_prefixed 138 , decode_u16_prefixed 139 , decode_chain_hash 140 , decode_channel_id 141 , decode_signature 142 , decode_point 143 , decode_payment_hash 144 , decode_payment_preimage 145 , decode_per_commitment_secret 146 , encode_short_channel_id 147 , decode_short_channel_id 148 , encode_satoshi 149 , decode_satoshi 150 , encode_milli_satoshi 151 , decode_milli_satoshi 152 ) where 153 154 import Lightning.Protocol.BOLT1.Codec 155 import Lightning.Protocol.BOLT1.Message 156 import Lightning.Protocol.BOLT1.Prim 157 import Lightning.Protocol.BOLT1.TLV