{-# OPTIONS_HADDOCK prune #-}

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveGeneric #-}

-- |
-- Module: Lightning.Protocol.BOLT7.Messages
-- Copyright: (c) 2025 Jared Tobin
-- License: MIT
-- Maintainer: Jared Tobin <jared@ppad.tech>
--
-- BOLT #7 gossip message type definitions.

module Lightning.Protocol.BOLT7.Messages (
  -- * Message types
    MsgType(..)
  , msgTypeCode

  -- * Channel announcement
  , ChannelAnnouncement(..)

  -- * Node announcement
  , NodeAnnouncement(..)

  -- * Channel update
  , ChannelUpdate(..)

  -- * Announcement signatures
  , AnnouncementSignatures(..)

  -- * Query messages
  , QueryShortChannelIds(..)
  , ReplyShortChannelIdsEnd(..)
  , QueryChannelRange(..)
  , ReplyChannelRange(..)
  , GossipTimestampFilter(..)

  -- * Union type
  , Message(..)
  ) where

import Control.DeepSeq (NFData)
import Data.ByteString (ByteString)
import Data.Word (Word8, Word16, Word32)  -- Word8 still used by other messages
import GHC.Generics (Generic)
import Lightning.Protocol.BOLT1 (TlvStream)
import Lightning.Protocol.BOLT7.Types

-- Message type codes ----------------------------------------------------------

-- | BOLT #7 message type codes.
data MsgType
  = MsgChannelAnnouncement       -- ^ 256
  | MsgNodeAnnouncement          -- ^ 257
  | MsgChannelUpdate             -- ^ 258
  | MsgAnnouncementSignatures    -- ^ 259
  | MsgQueryShortChannelIds      -- ^ 261
  | MsgReplyShortChannelIdsEnd   -- ^ 262
  | MsgQueryChannelRange         -- ^ 263
  | MsgReplyChannelRange         -- ^ 264
  | MsgGossipTimestampFilter     -- ^ 265
  deriving (MsgType -> MsgType -> Bool
(MsgType -> MsgType -> Bool)
-> (MsgType -> MsgType -> Bool) -> Eq MsgType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MsgType -> MsgType -> Bool
== :: MsgType -> MsgType -> Bool
$c/= :: MsgType -> MsgType -> Bool
/= :: MsgType -> MsgType -> Bool
Eq, Int -> MsgType -> ShowS
[MsgType] -> ShowS
MsgType -> String
(Int -> MsgType -> ShowS)
-> (MsgType -> String) -> ([MsgType] -> ShowS) -> Show MsgType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MsgType -> ShowS
showsPrec :: Int -> MsgType -> ShowS
$cshow :: MsgType -> String
show :: MsgType -> String
$cshowList :: [MsgType] -> ShowS
showList :: [MsgType] -> ShowS
Show, (forall x. MsgType -> Rep MsgType x)
-> (forall x. Rep MsgType x -> MsgType) -> Generic MsgType
forall x. Rep MsgType x -> MsgType
forall x. MsgType -> Rep MsgType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MsgType -> Rep MsgType x
from :: forall x. MsgType -> Rep MsgType x
$cto :: forall x. Rep MsgType x -> MsgType
to :: forall x. Rep MsgType x -> MsgType
Generic)

instance NFData MsgType

-- | Get numeric code for message type.
msgTypeCode :: MsgType -> Word16
msgTypeCode :: MsgType -> Word16
msgTypeCode MsgType
MsgChannelAnnouncement     = Word16
256
msgTypeCode MsgType
MsgNodeAnnouncement        = Word16
257
msgTypeCode MsgType
MsgChannelUpdate           = Word16
258
msgTypeCode MsgType
MsgAnnouncementSignatures  = Word16
259
msgTypeCode MsgType
MsgQueryShortChannelIds    = Word16
261
msgTypeCode MsgType
MsgReplyShortChannelIdsEnd = Word16
262
msgTypeCode MsgType
MsgQueryChannelRange       = Word16
263
msgTypeCode MsgType
MsgReplyChannelRange       = Word16
264
msgTypeCode MsgType
MsgGossipTimestampFilter   = Word16
265
{-# INLINE msgTypeCode #-}

-- Channel announcement --------------------------------------------------------

-- | channel_announcement message (type 256).
--
-- Announces a public channel to the network.
data ChannelAnnouncement = ChannelAnnouncement
  { ChannelAnnouncement -> Signature
channelAnnNodeSig1     :: !Signature     -- ^ Signature from node_id_1
  , ChannelAnnouncement -> Signature
channelAnnNodeSig2     :: !Signature     -- ^ Signature from node_id_2
  , ChannelAnnouncement -> Signature
channelAnnBitcoinSig1  :: !Signature     -- ^ Signature from bitcoin_key_1
  , ChannelAnnouncement -> Signature
channelAnnBitcoinSig2  :: !Signature     -- ^ Signature from bitcoin_key_2
  , ChannelAnnouncement -> FeatureBits
channelAnnFeatures     :: !FeatureBits   -- ^ Feature bits
  , ChannelAnnouncement -> ChainHash
channelAnnChainHash    :: !ChainHash     -- ^ Chain identifier
  , ChannelAnnouncement -> ShortChannelId
channelAnnShortChanId  :: !ShortChannelId -- ^ Short channel ID
  , ChannelAnnouncement -> NodeId
channelAnnNodeId1      :: !NodeId        -- ^ First node (lexicographically)
  , ChannelAnnouncement -> NodeId
channelAnnNodeId2      :: !NodeId        -- ^ Second node
  , ChannelAnnouncement -> Point
channelAnnBitcoinKey1  :: !Point         -- ^ Bitcoin key for node_id_1
  , ChannelAnnouncement -> Point
channelAnnBitcoinKey2  :: !Point         -- ^ Bitcoin key for node_id_2
  }
  deriving (ChannelAnnouncement -> ChannelAnnouncement -> Bool
(ChannelAnnouncement -> ChannelAnnouncement -> Bool)
-> (ChannelAnnouncement -> ChannelAnnouncement -> Bool)
-> Eq ChannelAnnouncement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChannelAnnouncement -> ChannelAnnouncement -> Bool
== :: ChannelAnnouncement -> ChannelAnnouncement -> Bool
$c/= :: ChannelAnnouncement -> ChannelAnnouncement -> Bool
/= :: ChannelAnnouncement -> ChannelAnnouncement -> Bool
Eq, Int -> ChannelAnnouncement -> ShowS
[ChannelAnnouncement] -> ShowS
ChannelAnnouncement -> String
(Int -> ChannelAnnouncement -> ShowS)
-> (ChannelAnnouncement -> String)
-> ([ChannelAnnouncement] -> ShowS)
-> Show ChannelAnnouncement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChannelAnnouncement -> ShowS
showsPrec :: Int -> ChannelAnnouncement -> ShowS
$cshow :: ChannelAnnouncement -> String
show :: ChannelAnnouncement -> String
$cshowList :: [ChannelAnnouncement] -> ShowS
showList :: [ChannelAnnouncement] -> ShowS
Show, (forall x. ChannelAnnouncement -> Rep ChannelAnnouncement x)
-> (forall x. Rep ChannelAnnouncement x -> ChannelAnnouncement)
-> Generic ChannelAnnouncement
forall x. Rep ChannelAnnouncement x -> ChannelAnnouncement
forall x. ChannelAnnouncement -> Rep ChannelAnnouncement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ChannelAnnouncement -> Rep ChannelAnnouncement x
from :: forall x. ChannelAnnouncement -> Rep ChannelAnnouncement x
$cto :: forall x. Rep ChannelAnnouncement x -> ChannelAnnouncement
to :: forall x. Rep ChannelAnnouncement x -> ChannelAnnouncement
Generic)

instance NFData ChannelAnnouncement

-- Node announcement -----------------------------------------------------------

-- | node_announcement message (type 257).
--
-- Advertises node metadata to the network.
data NodeAnnouncement = NodeAnnouncement
  { NodeAnnouncement -> Signature
nodeAnnSignature  :: !Signature      -- ^ Signature of message
  , NodeAnnouncement -> FeatureBits
nodeAnnFeatures   :: !FeatureBits    -- ^ Feature bits
  , NodeAnnouncement -> Timestamp
nodeAnnTimestamp  :: !Timestamp      -- ^ Unix timestamp
  , NodeAnnouncement -> NodeId
nodeAnnNodeId     :: !NodeId         -- ^ Node public key
  , NodeAnnouncement -> RgbColor
nodeAnnRgbColor   :: !RgbColor       -- ^ RGB color
  , NodeAnnouncement -> Alias
nodeAnnAlias      :: !Alias          -- ^ Node alias (32 bytes UTF-8)
  , NodeAnnouncement -> [Address]
nodeAnnAddresses  :: ![Address]      -- ^ List of addresses
  }
  deriving (NodeAnnouncement -> NodeAnnouncement -> Bool
(NodeAnnouncement -> NodeAnnouncement -> Bool)
-> (NodeAnnouncement -> NodeAnnouncement -> Bool)
-> Eq NodeAnnouncement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NodeAnnouncement -> NodeAnnouncement -> Bool
== :: NodeAnnouncement -> NodeAnnouncement -> Bool
$c/= :: NodeAnnouncement -> NodeAnnouncement -> Bool
/= :: NodeAnnouncement -> NodeAnnouncement -> Bool
Eq, Int -> NodeAnnouncement -> ShowS
[NodeAnnouncement] -> ShowS
NodeAnnouncement -> String
(Int -> NodeAnnouncement -> ShowS)
-> (NodeAnnouncement -> String)
-> ([NodeAnnouncement] -> ShowS)
-> Show NodeAnnouncement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NodeAnnouncement -> ShowS
showsPrec :: Int -> NodeAnnouncement -> ShowS
$cshow :: NodeAnnouncement -> String
show :: NodeAnnouncement -> String
$cshowList :: [NodeAnnouncement] -> ShowS
showList :: [NodeAnnouncement] -> ShowS
Show, (forall x. NodeAnnouncement -> Rep NodeAnnouncement x)
-> (forall x. Rep NodeAnnouncement x -> NodeAnnouncement)
-> Generic NodeAnnouncement
forall x. Rep NodeAnnouncement x -> NodeAnnouncement
forall x. NodeAnnouncement -> Rep NodeAnnouncement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NodeAnnouncement -> Rep NodeAnnouncement x
from :: forall x. NodeAnnouncement -> Rep NodeAnnouncement x
$cto :: forall x. Rep NodeAnnouncement x -> NodeAnnouncement
to :: forall x. Rep NodeAnnouncement x -> NodeAnnouncement
Generic)

instance NFData NodeAnnouncement

-- Channel update --------------------------------------------------------------

-- | channel_update message (type 258).
--
-- Communicates per-direction routing parameters.
data ChannelUpdate = ChannelUpdate
  { ChannelUpdate -> Signature
chanUpdateSignature      :: !Signature       -- ^ Signature of message
  , ChannelUpdate -> ChainHash
chanUpdateChainHash      :: !ChainHash       -- ^ Chain identifier
  , ChannelUpdate -> ShortChannelId
chanUpdateShortChanId    :: !ShortChannelId  -- ^ Short channel ID
  , ChannelUpdate -> Timestamp
chanUpdateTimestamp      :: !Timestamp       -- ^ Unix timestamp
  , ChannelUpdate -> MessageFlags
chanUpdateMsgFlags       :: !MessageFlags    -- ^ Message flags
  , ChannelUpdate -> ChannelFlags
chanUpdateChanFlags      :: !ChannelFlags    -- ^ Channel flags
  , ChannelUpdate -> CltvExpiryDelta
chanUpdateCltvExpDelta   :: !CltvExpiryDelta -- ^ CLTV expiry delta
  , ChannelUpdate -> HtlcMinimumMsat
chanUpdateHtlcMinMsat    :: !HtlcMinimumMsat -- ^ Minimum HTLC msat
  , ChannelUpdate -> FeeBaseMsat
chanUpdateFeeBaseMsat    :: !FeeBaseMsat     -- ^ Base fee msat
  , ChannelUpdate -> FeeProportionalMillionths
chanUpdateFeeProportional :: !FeeProportionalMillionths -- ^ Prop fee
  , ChannelUpdate -> Maybe HtlcMaximumMsat
chanUpdateHtlcMaxMsat    :: !(Maybe HtlcMaximumMsat) -- ^ Max HTLC (optional)
  }
  deriving (ChannelUpdate -> ChannelUpdate -> Bool
(ChannelUpdate -> ChannelUpdate -> Bool)
-> (ChannelUpdate -> ChannelUpdate -> Bool) -> Eq ChannelUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChannelUpdate -> ChannelUpdate -> Bool
== :: ChannelUpdate -> ChannelUpdate -> Bool
$c/= :: ChannelUpdate -> ChannelUpdate -> Bool
/= :: ChannelUpdate -> ChannelUpdate -> Bool
Eq, Int -> ChannelUpdate -> ShowS
[ChannelUpdate] -> ShowS
ChannelUpdate -> String
(Int -> ChannelUpdate -> ShowS)
-> (ChannelUpdate -> String)
-> ([ChannelUpdate] -> ShowS)
-> Show ChannelUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChannelUpdate -> ShowS
showsPrec :: Int -> ChannelUpdate -> ShowS
$cshow :: ChannelUpdate -> String
show :: ChannelUpdate -> String
$cshowList :: [ChannelUpdate] -> ShowS
showList :: [ChannelUpdate] -> ShowS
Show, (forall x. ChannelUpdate -> Rep ChannelUpdate x)
-> (forall x. Rep ChannelUpdate x -> ChannelUpdate)
-> Generic ChannelUpdate
forall x. Rep ChannelUpdate x -> ChannelUpdate
forall x. ChannelUpdate -> Rep ChannelUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ChannelUpdate -> Rep ChannelUpdate x
from :: forall x. ChannelUpdate -> Rep ChannelUpdate x
$cto :: forall x. Rep ChannelUpdate x -> ChannelUpdate
to :: forall x. Rep ChannelUpdate x -> ChannelUpdate
Generic)

instance NFData ChannelUpdate

-- Announcement signatures -----------------------------------------------------

-- | announcement_signatures message (type 259).
--
-- Sent between channel peers to enable channel announcement.
data AnnouncementSignatures = AnnouncementSignatures
  { AnnouncementSignatures -> ChannelId
annSigChannelId     :: !ChannelId       -- ^ Channel ID
  , AnnouncementSignatures -> ShortChannelId
annSigShortChanId   :: !ShortChannelId  -- ^ Short channel ID
  , AnnouncementSignatures -> Signature
annSigNodeSig       :: !Signature       -- ^ Node signature
  , AnnouncementSignatures -> Signature
annSigBitcoinSig    :: !Signature       -- ^ Bitcoin signature
  }
  deriving (AnnouncementSignatures -> AnnouncementSignatures -> Bool
(AnnouncementSignatures -> AnnouncementSignatures -> Bool)
-> (AnnouncementSignatures -> AnnouncementSignatures -> Bool)
-> Eq AnnouncementSignatures
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AnnouncementSignatures -> AnnouncementSignatures -> Bool
== :: AnnouncementSignatures -> AnnouncementSignatures -> Bool
$c/= :: AnnouncementSignatures -> AnnouncementSignatures -> Bool
/= :: AnnouncementSignatures -> AnnouncementSignatures -> Bool
Eq, Int -> AnnouncementSignatures -> ShowS
[AnnouncementSignatures] -> ShowS
AnnouncementSignatures -> String
(Int -> AnnouncementSignatures -> ShowS)
-> (AnnouncementSignatures -> String)
-> ([AnnouncementSignatures] -> ShowS)
-> Show AnnouncementSignatures
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AnnouncementSignatures -> ShowS
showsPrec :: Int -> AnnouncementSignatures -> ShowS
$cshow :: AnnouncementSignatures -> String
show :: AnnouncementSignatures -> String
$cshowList :: [AnnouncementSignatures] -> ShowS
showList :: [AnnouncementSignatures] -> ShowS
Show, (forall x. AnnouncementSignatures -> Rep AnnouncementSignatures x)
-> (forall x.
    Rep AnnouncementSignatures x -> AnnouncementSignatures)
-> Generic AnnouncementSignatures
forall x. Rep AnnouncementSignatures x -> AnnouncementSignatures
forall x. AnnouncementSignatures -> Rep AnnouncementSignatures x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AnnouncementSignatures -> Rep AnnouncementSignatures x
from :: forall x. AnnouncementSignatures -> Rep AnnouncementSignatures x
$cto :: forall x. Rep AnnouncementSignatures x -> AnnouncementSignatures
to :: forall x. Rep AnnouncementSignatures x -> AnnouncementSignatures
Generic)

instance NFData AnnouncementSignatures

-- Query messages --------------------------------------------------------------

-- | query_short_channel_ids message (type 261).
--
-- Requests information about specific channels.
data QueryShortChannelIds = QueryShortChannelIds
  { QueryShortChannelIds -> ChainHash
queryScidsChainHash :: !ChainHash    -- ^ Chain identifier
  , QueryShortChannelIds -> ByteString
queryScidsData      :: !ByteString   -- ^ Encoded short_channel_ids
  , QueryShortChannelIds -> TlvStream
queryScidsTlvs      :: !TlvStream    -- ^ Optional TLV (query_flags)
  }
  deriving (QueryShortChannelIds -> QueryShortChannelIds -> Bool
(QueryShortChannelIds -> QueryShortChannelIds -> Bool)
-> (QueryShortChannelIds -> QueryShortChannelIds -> Bool)
-> Eq QueryShortChannelIds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: QueryShortChannelIds -> QueryShortChannelIds -> Bool
== :: QueryShortChannelIds -> QueryShortChannelIds -> Bool
$c/= :: QueryShortChannelIds -> QueryShortChannelIds -> Bool
/= :: QueryShortChannelIds -> QueryShortChannelIds -> Bool
Eq, Int -> QueryShortChannelIds -> ShowS
[QueryShortChannelIds] -> ShowS
QueryShortChannelIds -> String
(Int -> QueryShortChannelIds -> ShowS)
-> (QueryShortChannelIds -> String)
-> ([QueryShortChannelIds] -> ShowS)
-> Show QueryShortChannelIds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> QueryShortChannelIds -> ShowS
showsPrec :: Int -> QueryShortChannelIds -> ShowS
$cshow :: QueryShortChannelIds -> String
show :: QueryShortChannelIds -> String
$cshowList :: [QueryShortChannelIds] -> ShowS
showList :: [QueryShortChannelIds] -> ShowS
Show, (forall x. QueryShortChannelIds -> Rep QueryShortChannelIds x)
-> (forall x. Rep QueryShortChannelIds x -> QueryShortChannelIds)
-> Generic QueryShortChannelIds
forall x. Rep QueryShortChannelIds x -> QueryShortChannelIds
forall x. QueryShortChannelIds -> Rep QueryShortChannelIds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. QueryShortChannelIds -> Rep QueryShortChannelIds x
from :: forall x. QueryShortChannelIds -> Rep QueryShortChannelIds x
$cto :: forall x. Rep QueryShortChannelIds x -> QueryShortChannelIds
to :: forall x. Rep QueryShortChannelIds x -> QueryShortChannelIds
Generic)

instance NFData QueryShortChannelIds

-- | reply_short_channel_ids_end message (type 262).
--
-- Concludes response to query_short_channel_ids.
data ReplyShortChannelIdsEnd = ReplyShortChannelIdsEnd
  { ReplyShortChannelIdsEnd -> ChainHash
replyScidsChainHash    :: !ChainHash  -- ^ Chain identifier
  , ReplyShortChannelIdsEnd -> Word8
replyScidsFullInfo     :: !Word8      -- ^ 1 if complete, 0 otherwise
  }
  deriving (ReplyShortChannelIdsEnd -> ReplyShortChannelIdsEnd -> Bool
(ReplyShortChannelIdsEnd -> ReplyShortChannelIdsEnd -> Bool)
-> (ReplyShortChannelIdsEnd -> ReplyShortChannelIdsEnd -> Bool)
-> Eq ReplyShortChannelIdsEnd
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReplyShortChannelIdsEnd -> ReplyShortChannelIdsEnd -> Bool
== :: ReplyShortChannelIdsEnd -> ReplyShortChannelIdsEnd -> Bool
$c/= :: ReplyShortChannelIdsEnd -> ReplyShortChannelIdsEnd -> Bool
/= :: ReplyShortChannelIdsEnd -> ReplyShortChannelIdsEnd -> Bool
Eq, Int -> ReplyShortChannelIdsEnd -> ShowS
[ReplyShortChannelIdsEnd] -> ShowS
ReplyShortChannelIdsEnd -> String
(Int -> ReplyShortChannelIdsEnd -> ShowS)
-> (ReplyShortChannelIdsEnd -> String)
-> ([ReplyShortChannelIdsEnd] -> ShowS)
-> Show ReplyShortChannelIdsEnd
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReplyShortChannelIdsEnd -> ShowS
showsPrec :: Int -> ReplyShortChannelIdsEnd -> ShowS
$cshow :: ReplyShortChannelIdsEnd -> String
show :: ReplyShortChannelIdsEnd -> String
$cshowList :: [ReplyShortChannelIdsEnd] -> ShowS
showList :: [ReplyShortChannelIdsEnd] -> ShowS
Show, (forall x.
 ReplyShortChannelIdsEnd -> Rep ReplyShortChannelIdsEnd x)
-> (forall x.
    Rep ReplyShortChannelIdsEnd x -> ReplyShortChannelIdsEnd)
-> Generic ReplyShortChannelIdsEnd
forall x. Rep ReplyShortChannelIdsEnd x -> ReplyShortChannelIdsEnd
forall x. ReplyShortChannelIdsEnd -> Rep ReplyShortChannelIdsEnd x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReplyShortChannelIdsEnd -> Rep ReplyShortChannelIdsEnd x
from :: forall x. ReplyShortChannelIdsEnd -> Rep ReplyShortChannelIdsEnd x
$cto :: forall x. Rep ReplyShortChannelIdsEnd x -> ReplyShortChannelIdsEnd
to :: forall x. Rep ReplyShortChannelIdsEnd x -> ReplyShortChannelIdsEnd
Generic)

instance NFData ReplyShortChannelIdsEnd

-- | query_channel_range message (type 263).
--
-- Queries channels within a block range.
data QueryChannelRange = QueryChannelRange
  { QueryChannelRange -> ChainHash
queryRangeChainHash     :: !ChainHash  -- ^ Chain identifier
  , QueryChannelRange -> Timestamp
queryRangeFirstBlock    :: !Word32     -- ^ First block number
  , QueryChannelRange -> Timestamp
queryRangeNumBlocks     :: !Word32     -- ^ Number of blocks
  , QueryChannelRange -> TlvStream
queryRangeTlvs          :: !TlvStream  -- ^ Optional TLV (query_option)
  }
  deriving (QueryChannelRange -> QueryChannelRange -> Bool
(QueryChannelRange -> QueryChannelRange -> Bool)
-> (QueryChannelRange -> QueryChannelRange -> Bool)
-> Eq QueryChannelRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: QueryChannelRange -> QueryChannelRange -> Bool
== :: QueryChannelRange -> QueryChannelRange -> Bool
$c/= :: QueryChannelRange -> QueryChannelRange -> Bool
/= :: QueryChannelRange -> QueryChannelRange -> Bool
Eq, Int -> QueryChannelRange -> ShowS
[QueryChannelRange] -> ShowS
QueryChannelRange -> String
(Int -> QueryChannelRange -> ShowS)
-> (QueryChannelRange -> String)
-> ([QueryChannelRange] -> ShowS)
-> Show QueryChannelRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> QueryChannelRange -> ShowS
showsPrec :: Int -> QueryChannelRange -> ShowS
$cshow :: QueryChannelRange -> String
show :: QueryChannelRange -> String
$cshowList :: [QueryChannelRange] -> ShowS
showList :: [QueryChannelRange] -> ShowS
Show, (forall x. QueryChannelRange -> Rep QueryChannelRange x)
-> (forall x. Rep QueryChannelRange x -> QueryChannelRange)
-> Generic QueryChannelRange
forall x. Rep QueryChannelRange x -> QueryChannelRange
forall x. QueryChannelRange -> Rep QueryChannelRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. QueryChannelRange -> Rep QueryChannelRange x
from :: forall x. QueryChannelRange -> Rep QueryChannelRange x
$cto :: forall x. Rep QueryChannelRange x -> QueryChannelRange
to :: forall x. Rep QueryChannelRange x -> QueryChannelRange
Generic)

instance NFData QueryChannelRange

-- | reply_channel_range message (type 264).
--
-- Responds to query_channel_range with channel IDs.
data ReplyChannelRange = ReplyChannelRange
  { ReplyChannelRange -> ChainHash
replyRangeChainHash   :: !ChainHash    -- ^ Chain identifier
  , ReplyChannelRange -> Timestamp
replyRangeFirstBlock  :: !Word32       -- ^ First block number
  , ReplyChannelRange -> Timestamp
replyRangeNumBlocks   :: !Word32       -- ^ Number of blocks
  , ReplyChannelRange -> Word8
replyRangeSyncComplete :: !Word8       -- ^ 1 if sync complete
  , ReplyChannelRange -> ByteString
replyRangeData        :: !ByteString   -- ^ Encoded short_channel_ids
  , ReplyChannelRange -> TlvStream
replyRangeTlvs        :: !TlvStream    -- ^ Optional TLVs
  }
  deriving (ReplyChannelRange -> ReplyChannelRange -> Bool
(ReplyChannelRange -> ReplyChannelRange -> Bool)
-> (ReplyChannelRange -> ReplyChannelRange -> Bool)
-> Eq ReplyChannelRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReplyChannelRange -> ReplyChannelRange -> Bool
== :: ReplyChannelRange -> ReplyChannelRange -> Bool
$c/= :: ReplyChannelRange -> ReplyChannelRange -> Bool
/= :: ReplyChannelRange -> ReplyChannelRange -> Bool
Eq, Int -> ReplyChannelRange -> ShowS
[ReplyChannelRange] -> ShowS
ReplyChannelRange -> String
(Int -> ReplyChannelRange -> ShowS)
-> (ReplyChannelRange -> String)
-> ([ReplyChannelRange] -> ShowS)
-> Show ReplyChannelRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReplyChannelRange -> ShowS
showsPrec :: Int -> ReplyChannelRange -> ShowS
$cshow :: ReplyChannelRange -> String
show :: ReplyChannelRange -> String
$cshowList :: [ReplyChannelRange] -> ShowS
showList :: [ReplyChannelRange] -> ShowS
Show, (forall x. ReplyChannelRange -> Rep ReplyChannelRange x)
-> (forall x. Rep ReplyChannelRange x -> ReplyChannelRange)
-> Generic ReplyChannelRange
forall x. Rep ReplyChannelRange x -> ReplyChannelRange
forall x. ReplyChannelRange -> Rep ReplyChannelRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ReplyChannelRange -> Rep ReplyChannelRange x
from :: forall x. ReplyChannelRange -> Rep ReplyChannelRange x
$cto :: forall x. Rep ReplyChannelRange x -> ReplyChannelRange
to :: forall x. Rep ReplyChannelRange x -> ReplyChannelRange
Generic)

instance NFData ReplyChannelRange

-- | gossip_timestamp_filter message (type 265).
--
-- Constrains which gossip messages are relayed.
data GossipTimestampFilter = GossipTimestampFilter
  { GossipTimestampFilter -> ChainHash
gossipFilterChainHash     :: !ChainHash  -- ^ Chain identifier
  , GossipTimestampFilter -> Timestamp
gossipFilterFirstTimestamp :: !Word32    -- ^ First timestamp
  , GossipTimestampFilter -> Timestamp
gossipFilterTimestampRange :: !Word32    -- ^ Timestamp range
  }
  deriving (GossipTimestampFilter -> GossipTimestampFilter -> Bool
(GossipTimestampFilter -> GossipTimestampFilter -> Bool)
-> (GossipTimestampFilter -> GossipTimestampFilter -> Bool)
-> Eq GossipTimestampFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GossipTimestampFilter -> GossipTimestampFilter -> Bool
== :: GossipTimestampFilter -> GossipTimestampFilter -> Bool
$c/= :: GossipTimestampFilter -> GossipTimestampFilter -> Bool
/= :: GossipTimestampFilter -> GossipTimestampFilter -> Bool
Eq, Int -> GossipTimestampFilter -> ShowS
[GossipTimestampFilter] -> ShowS
GossipTimestampFilter -> String
(Int -> GossipTimestampFilter -> ShowS)
-> (GossipTimestampFilter -> String)
-> ([GossipTimestampFilter] -> ShowS)
-> Show GossipTimestampFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GossipTimestampFilter -> ShowS
showsPrec :: Int -> GossipTimestampFilter -> ShowS
$cshow :: GossipTimestampFilter -> String
show :: GossipTimestampFilter -> String
$cshowList :: [GossipTimestampFilter] -> ShowS
showList :: [GossipTimestampFilter] -> ShowS
Show, (forall x. GossipTimestampFilter -> Rep GossipTimestampFilter x)
-> (forall x. Rep GossipTimestampFilter x -> GossipTimestampFilter)
-> Generic GossipTimestampFilter
forall x. Rep GossipTimestampFilter x -> GossipTimestampFilter
forall x. GossipTimestampFilter -> Rep GossipTimestampFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GossipTimestampFilter -> Rep GossipTimestampFilter x
from :: forall x. GossipTimestampFilter -> Rep GossipTimestampFilter x
$cto :: forall x. Rep GossipTimestampFilter x -> GossipTimestampFilter
to :: forall x. Rep GossipTimestampFilter x -> GossipTimestampFilter
Generic)

instance NFData GossipTimestampFilter

-- Union type ------------------------------------------------------------------

-- | Union of all BOLT #7 message types.
data Message
  = MsgChanAnn !ChannelAnnouncement
  | MsgNodeAnn !NodeAnnouncement
  | MsgChanUpd !ChannelUpdate
  | MsgAnnSig  !AnnouncementSignatures
  | MsgQueryScids !QueryShortChannelIds
  | MsgReplyScids !ReplyShortChannelIdsEnd
  | MsgQueryRange !QueryChannelRange
  | MsgReplyRange !ReplyChannelRange
  | MsgGossipFilter !GossipTimestampFilter
  deriving (Message -> Message -> Bool
(Message -> Message -> Bool)
-> (Message -> Message -> Bool) -> Eq Message
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Message -> Message -> Bool
== :: Message -> Message -> Bool
$c/= :: Message -> Message -> Bool
/= :: Message -> Message -> Bool
Eq, Int -> Message -> ShowS
[Message] -> ShowS
Message -> String
(Int -> Message -> ShowS)
-> (Message -> String) -> ([Message] -> ShowS) -> Show Message
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Message -> ShowS
showsPrec :: Int -> Message -> ShowS
$cshow :: Message -> String
show :: Message -> String
$cshowList :: [Message] -> ShowS
showList :: [Message] -> ShowS
Show, (forall x. Message -> Rep Message x)
-> (forall x. Rep Message x -> Message) -> Generic Message
forall x. Rep Message x -> Message
forall x. Message -> Rep Message x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Message -> Rep Message x
from :: forall x. Message -> Rep Message x
$cto :: forall x. Rep Message x -> Message
to :: forall x. Rep Message x -> Message
Generic)

instance NFData Message