{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE DeriveGeneric #-}

-- |
-- Module: Lightning.Protocol.BOLT7.Messages
-- Copyright: (c) 2025 Jared Tobin
-- License: MIT
-- Maintainer: Jared Tobin <jared@ppad.tech>
--
-- The messages defined by BOLT #7.

module Lightning.Protocol.BOLT7.Messages (
    Message(..)
  , message_type
  , ChannelAnnouncement(..)
  , NodeAnnouncement(..)
  , ChannelUpdate(..)
  , AnnouncementSignatures(..)
  , QueryShortChannelIds(..)
  , ReplyShortChannelIdsEnd(..)
  , QueryChannelRange(..)
  , ReplyChannelRange(..)
  , GossipTimestampFilter(..)
  ) where

import Control.DeepSeq (NFData)
import qualified Data.ByteString as BS
import Data.Word (Word16, Word32)
import GHC.Generics (Generic)
import Lightning.Protocol.BOLT1
  ( ChainHash, ChannelId, MilliSatoshi, Point, ShortChannelId
  , Signature, TlvStream )
import qualified Lightning.Protocol.BOLT9 as BOLT9
import Lightning.Protocol.BOLT7.Types

-- | The @channel_announcement@ message (type 256).
data ChannelAnnouncement = ChannelAnnouncement
  { ChannelAnnouncement -> Signature
ca_node_signature_1    :: !Signature
  , ChannelAnnouncement -> Signature
ca_node_signature_2    :: !Signature
  , ChannelAnnouncement -> Signature
ca_bitcoin_signature_1 :: !Signature
  , ChannelAnnouncement -> Signature
ca_bitcoin_signature_2 :: !Signature
  , ChannelAnnouncement -> FeatureVector
ca_features            :: !BOLT9.FeatureVector
  , ChannelAnnouncement -> ChainHash
ca_chain_hash          :: !ChainHash
  , ChannelAnnouncement -> ShortChannelId
ca_short_channel_id    :: {-# UNPACK #-} !ShortChannelId
  , ChannelAnnouncement -> Point
ca_node_id_1           :: !Point
    -- ^ the lexicographically lesser node id
  , ChannelAnnouncement -> Point
ca_node_id_2           :: !Point
  , ChannelAnnouncement -> Point
ca_bitcoin_key_1       :: !Point
  , ChannelAnnouncement -> Point
ca_bitcoin_key_2       :: !Point
  , ChannelAnnouncement -> TlvStream
ca_tlvs                :: !TlvStream
    -- ^ extension TLV records (all unknown odd)
  } 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

-- | The @node_announcement@ message (type 257).
data NodeAnnouncement = NodeAnnouncement
  { NodeAnnouncement -> Signature
na_signature         :: !Signature
  , NodeAnnouncement -> FeatureVector
na_features          :: !BOLT9.FeatureVector
  , NodeAnnouncement -> Word32
na_timestamp         :: {-# UNPACK #-} !Word32
  , NodeAnnouncement -> Point
na_node_id           :: !Point
  , NodeAnnouncement -> RgbColor
na_rgb_color         :: !RgbColor
  , NodeAnnouncement -> Alias
na_alias             :: !Alias
  , NodeAnnouncement -> [Address]
na_addresses         :: ![Address]
    -- ^ address descriptors of known types, in order
  , NodeAnnouncement -> ByteString
na_unknown_addresses :: !BS.ByteString
    -- ^ the address bytes from the first descriptor of an unknown type
    --   on (empty if there is none), kept as received
  , NodeAnnouncement -> TlvStream
na_tlvs              :: !TlvStream
    -- ^ extension TLV records (all unknown odd)
  } 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

-- | The @channel_update@ message (type 258).
data ChannelUpdate = ChannelUpdate
  { ChannelUpdate -> Signature
cu_signature                   :: !Signature
  , ChannelUpdate -> ChainHash
cu_chain_hash                  :: !ChainHash
  , ChannelUpdate -> ShortChannelId
cu_short_channel_id            :: {-# UNPACK #-} !ShortChannelId
  , ChannelUpdate -> Word32
cu_timestamp                   :: {-# UNPACK #-} !Word32
  , ChannelUpdate -> MessageFlags
cu_message_flags               :: {-# UNPACK #-} !MessageFlags
  , ChannelUpdate -> ChannelFlags
cu_channel_flags               :: {-# UNPACK #-} !ChannelFlags
  , ChannelUpdate -> Word16
cu_cltv_expiry_delta           :: {-# UNPACK #-} !Word16
  , ChannelUpdate -> MilliSatoshi
cu_htlc_minimum_msat           :: {-# UNPACK #-} !MilliSatoshi
  , ChannelUpdate -> Word32
cu_fee_base_msat               :: {-# UNPACK #-} !Word32
  , ChannelUpdate -> Word32
cu_fee_proportional_millionths :: {-# UNPACK #-} !Word32
  , ChannelUpdate -> MilliSatoshi
cu_htlc_maximum_msat           :: {-# UNPACK #-} !MilliSatoshi
  , ChannelUpdate -> TlvStream
cu_tlvs                        :: !TlvStream
    -- ^ extension TLV records (all unknown odd)
  } 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

-- | The @announcement_signatures@ message (type 259).
data AnnouncementSignatures = AnnouncementSignatures
  { AnnouncementSignatures -> ChannelId
as_channel_id        :: !ChannelId
  , AnnouncementSignatures -> ShortChannelId
as_short_channel_id  :: {-# UNPACK #-} !ShortChannelId
  , AnnouncementSignatures -> Signature
as_node_signature    :: !Signature
  , AnnouncementSignatures -> Signature
as_bitcoin_signature :: !Signature
  , AnnouncementSignatures -> TlvStream
as_tlvs              :: !TlvStream
    -- ^ extension TLV records (all unknown odd)
  } 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

-- | The @query_short_channel_ids@ message (type 261).
data QueryShortChannelIds = QueryShortChannelIds
  { QueryShortChannelIds -> ChainHash
qsci_chain_hash        :: !ChainHash
  , QueryShortChannelIds -> [ShortChannelId]
qsci_short_channel_ids :: ![ShortChannelId]
  , QueryShortChannelIds -> Maybe [QueryFlags]
qsci_query_flags       :: !(Maybe [QueryFlags])
    -- ^ @query_flags@ (TLV type 1): one per short channel id
  , QueryShortChannelIds -> TlvStream
qsci_tlvs              :: !TlvStream
    -- ^ unknown odd TLV records
  } 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

-- | The @reply_short_channel_ids_end@ message (type 262).
data ReplyShortChannelIdsEnd = ReplyShortChannelIdsEnd
  { ReplyShortChannelIdsEnd -> ChainHash
rsce_chain_hash       :: !ChainHash
  , ReplyShortChannelIdsEnd -> Bool
rsce_full_information :: !Bool
  , ReplyShortChannelIdsEnd -> TlvStream
rsce_tlvs             :: !TlvStream
    -- ^ extension TLV records (all unknown odd)
  } 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

-- | The @query_channel_range@ message (type 263).
data QueryChannelRange = QueryChannelRange
  { QueryChannelRange -> ChainHash
qcr_chain_hash       :: !ChainHash
  , QueryChannelRange -> Word32
qcr_first_blocknum   :: {-# UNPACK #-} !Word32
  , QueryChannelRange -> Word32
qcr_number_of_blocks :: {-# UNPACK #-} !Word32
  , QueryChannelRange -> Maybe QueryOption
qcr_query_option     :: !(Maybe QueryOption)
    -- ^ @query_option@ (TLV type 1)
  , QueryChannelRange -> TlvStream
qcr_tlvs             :: !TlvStream
    -- ^ unknown odd TLV records
  } 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

-- | The @reply_channel_range@ message (type 264).
data ReplyChannelRange = ReplyChannelRange
  { ReplyChannelRange -> ChainHash
rcr_chain_hash        :: !ChainHash
  , ReplyChannelRange -> Word32
rcr_first_blocknum    :: {-# UNPACK #-} !Word32
  , ReplyChannelRange -> Word32
rcr_number_of_blocks  :: {-# UNPACK #-} !Word32
  , ReplyChannelRange -> Bool
rcr_sync_complete     :: !Bool
  , ReplyChannelRange -> [ShortChannelId]
rcr_short_channel_ids :: ![ShortChannelId]
  , ReplyChannelRange -> Maybe [ChannelUpdateTimestamps]
rcr_timestamps        :: !(Maybe [ChannelUpdateTimestamps])
    -- ^ @timestamps_tlv@ (TLV type 1): one per short channel id
  , ReplyChannelRange -> Maybe [ChannelUpdateChecksums]
rcr_checksums         :: !(Maybe [ChannelUpdateChecksums])
    -- ^ @checksums_tlv@ (TLV type 3): one per short channel id
  , ReplyChannelRange -> TlvStream
rcr_tlvs              :: !TlvStream
    -- ^ unknown odd TLV records
  } 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

-- | The @gossip_timestamp_filter@ message (type 265).
data GossipTimestampFilter = GossipTimestampFilter
  { GossipTimestampFilter -> ChainHash
gtf_chain_hash      :: !ChainHash
  , GossipTimestampFilter -> Word32
gtf_first_timestamp :: {-# UNPACK #-} !Word32
  , GossipTimestampFilter -> Word32
gtf_timestamp_range :: {-# UNPACK #-} !Word32
  , GossipTimestampFilter -> TlvStream
gtf_tlvs            :: !TlvStream
    -- ^ extension TLV records (all unknown odd)
  } 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

-- | A BOLT #7 message.
data Message
  = MsgChannelAnnouncement !ChannelAnnouncement
  | MsgNodeAnnouncement !NodeAnnouncement
  | MsgChannelUpdate !ChannelUpdate
  | MsgAnnouncementSignatures !AnnouncementSignatures
  | MsgQueryShortChannelIds !QueryShortChannelIds
  | MsgReplyShortChannelIdsEnd !ReplyShortChannelIdsEnd
  | MsgQueryChannelRange !QueryChannelRange
  | MsgReplyChannelRange !ReplyChannelRange
  | MsgGossipTimestampFilter !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

-- | The message type of a 'Message'.
message_type :: Message -> Word16
message_type :: Message -> Word16
message_type Message
m = case Message
m of
  MsgChannelAnnouncement ChannelAnnouncement
_     -> Word16
256
  MsgNodeAnnouncement NodeAnnouncement
_        -> Word16
257
  MsgChannelUpdate ChannelUpdate
_           -> Word16
258
  MsgAnnouncementSignatures AnnouncementSignatures
_  -> Word16
259
  MsgQueryShortChannelIds QueryShortChannelIds
_    -> Word16
261
  MsgReplyShortChannelIdsEnd ReplyShortChannelIdsEnd
_ -> Word16
262
  MsgQueryChannelRange QueryChannelRange
_       -> Word16
263
  MsgReplyChannelRange ReplyChannelRange
_       -> Word16
264
  MsgGossipTimestampFilter GossipTimestampFilter
_   -> Word16
265