{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE DeriveGeneric #-}
module Lightning.Protocol.BOLT4.Types (
OnionPacket(..)
, HopPayloads(..)
, hop_payloads
, un_hop_payloads
, Hmac32(..)
, hmac32
, un_hmac32
, HopPayload(..)
, empty_hop_payload
, PaymentData(..)
, PaymentSecret(..)
, payment_secret
, un_payment_secret
, BlindedPath(..)
, BlindedHop(..)
, BlindedHopData(..)
, empty_blinded_hop_data
, PaymentRelay(..)
, PaymentConstraints(..)
, BlindedInfo(..)
, FailureMessage(..)
, Failure(..)
, OnionHash(..)
, onion_hash
, un_onion_hash
, failure_code
, is_badonion
, is_perm
, is_node
, is_update
, DecodeError(..)
, EncodeError(..)
, ProcessError(..)
) where
import Control.DeepSeq (NFData(..))
import Data.Bits ((.&.))
import qualified Data.ByteString as BS
import Data.Word (Word8, Word16, Word32, Word64)
import GHC.Generics (Generic)
import qualified Lightning.Protocol.BOLT1 as BOLT1
import qualified Lightning.Protocol.BOLT4.Prim as P
import qualified Lightning.Protocol.BOLT9 as BOLT9
data OnionPacket = OnionPacket
{ OnionPacket -> Word8
onion_version :: {-# UNPACK #-} !Word8
, OnionPacket -> Point
onion_public_key :: !BOLT1.Point
, OnionPacket -> HopPayloads
onion_hop_payloads :: !HopPayloads
, OnionPacket -> Hmac32
onion_hmac :: !Hmac32
} deriving (OnionPacket -> OnionPacket -> Bool
(OnionPacket -> OnionPacket -> Bool)
-> (OnionPacket -> OnionPacket -> Bool) -> Eq OnionPacket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OnionPacket -> OnionPacket -> Bool
== :: OnionPacket -> OnionPacket -> Bool
$c/= :: OnionPacket -> OnionPacket -> Bool
/= :: OnionPacket -> OnionPacket -> Bool
Eq, Int -> OnionPacket -> ShowS
[OnionPacket] -> ShowS
OnionPacket -> String
(Int -> OnionPacket -> ShowS)
-> (OnionPacket -> String)
-> ([OnionPacket] -> ShowS)
-> Show OnionPacket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OnionPacket -> ShowS
showsPrec :: Int -> OnionPacket -> ShowS
$cshow :: OnionPacket -> String
show :: OnionPacket -> String
$cshowList :: [OnionPacket] -> ShowS
showList :: [OnionPacket] -> ShowS
Show, (forall x. OnionPacket -> Rep OnionPacket x)
-> (forall x. Rep OnionPacket x -> OnionPacket)
-> Generic OnionPacket
forall x. Rep OnionPacket x -> OnionPacket
forall x. OnionPacket -> Rep OnionPacket x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. OnionPacket -> Rep OnionPacket x
from :: forall x. OnionPacket -> Rep OnionPacket x
$cto :: forall x. Rep OnionPacket x -> OnionPacket
to :: forall x. Rep OnionPacket x -> OnionPacket
Generic)
instance NFData OnionPacket
newtype HopPayloads = HopPayloads BS.ByteString
deriving (HopPayloads -> HopPayloads -> Bool
(HopPayloads -> HopPayloads -> Bool)
-> (HopPayloads -> HopPayloads -> Bool) -> Eq HopPayloads
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HopPayloads -> HopPayloads -> Bool
== :: HopPayloads -> HopPayloads -> Bool
$c/= :: HopPayloads -> HopPayloads -> Bool
/= :: HopPayloads -> HopPayloads -> Bool
Eq, Int -> HopPayloads -> ShowS
[HopPayloads] -> ShowS
HopPayloads -> String
(Int -> HopPayloads -> ShowS)
-> (HopPayloads -> String)
-> ([HopPayloads] -> ShowS)
-> Show HopPayloads
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HopPayloads -> ShowS
showsPrec :: Int -> HopPayloads -> ShowS
$cshow :: HopPayloads -> String
show :: HopPayloads -> String
$cshowList :: [HopPayloads] -> ShowS
showList :: [HopPayloads] -> ShowS
Show, (forall x. HopPayloads -> Rep HopPayloads x)
-> (forall x. Rep HopPayloads x -> HopPayloads)
-> Generic HopPayloads
forall x. Rep HopPayloads x -> HopPayloads
forall x. HopPayloads -> Rep HopPayloads x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HopPayloads -> Rep HopPayloads x
from :: forall x. HopPayloads -> Rep HopPayloads x
$cto :: forall x. Rep HopPayloads x -> HopPayloads
to :: forall x. Rep HopPayloads x -> HopPayloads
Generic)
instance NFData HopPayloads
hop_payloads :: BS.ByteString -> Maybe HopPayloads
hop_payloads :: ByteString -> Maybe HopPayloads
hop_payloads ByteString
bs
| ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1300 = HopPayloads -> Maybe HopPayloads
forall a. a -> Maybe a
Just (ByteString -> HopPayloads
HopPayloads ByteString
bs)
| Bool
otherwise = Maybe HopPayloads
forall a. Maybe a
Nothing
{-# INLINE hop_payloads #-}
un_hop_payloads :: HopPayloads -> BS.ByteString
un_hop_payloads :: HopPayloads -> ByteString
un_hop_payloads (HopPayloads ByteString
bs) = ByteString
bs
{-# INLINE un_hop_payloads #-}
newtype Hmac32 = Hmac32 BS.ByteString
deriving (Hmac32 -> Hmac32 -> Bool
(Hmac32 -> Hmac32 -> Bool)
-> (Hmac32 -> Hmac32 -> Bool) -> Eq Hmac32
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Hmac32 -> Hmac32 -> Bool
== :: Hmac32 -> Hmac32 -> Bool
$c/= :: Hmac32 -> Hmac32 -> Bool
/= :: Hmac32 -> Hmac32 -> Bool
Eq, Int -> Hmac32 -> ShowS
[Hmac32] -> ShowS
Hmac32 -> String
(Int -> Hmac32 -> ShowS)
-> (Hmac32 -> String) -> ([Hmac32] -> ShowS) -> Show Hmac32
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Hmac32 -> ShowS
showsPrec :: Int -> Hmac32 -> ShowS
$cshow :: Hmac32 -> String
show :: Hmac32 -> String
$cshowList :: [Hmac32] -> ShowS
showList :: [Hmac32] -> ShowS
Show, (forall x. Hmac32 -> Rep Hmac32 x)
-> (forall x. Rep Hmac32 x -> Hmac32) -> Generic Hmac32
forall x. Rep Hmac32 x -> Hmac32
forall x. Hmac32 -> Rep Hmac32 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Hmac32 -> Rep Hmac32 x
from :: forall x. Hmac32 -> Rep Hmac32 x
$cto :: forall x. Rep Hmac32 x -> Hmac32
to :: forall x. Rep Hmac32 x -> Hmac32
Generic)
instance NFData Hmac32
hmac32 :: BS.ByteString -> Maybe Hmac32
hmac32 :: ByteString -> Maybe Hmac32
hmac32 ByteString
bs
| ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = Hmac32 -> Maybe Hmac32
forall a. a -> Maybe a
Just (ByteString -> Hmac32
Hmac32 ByteString
bs)
| Bool
otherwise = Maybe Hmac32
forall a. Maybe a
Nothing
{-# INLINE hmac32 #-}
un_hmac32 :: Hmac32 -> BS.ByteString
un_hmac32 :: Hmac32 -> ByteString
un_hmac32 (Hmac32 ByteString
bs) = ByteString
bs
{-# INLINE un_hmac32 #-}
data HopPayload = HopPayload
{ HopPayload -> Maybe MilliSatoshi
hp_amt_to_forward :: !(Maybe BOLT1.MilliSatoshi)
, HopPayload -> Maybe Word32
hp_outgoing_cltv_value :: !(Maybe Word32)
, HopPayload -> Maybe ShortChannelId
hp_short_channel_id :: !(Maybe BOLT1.ShortChannelId)
, HopPayload -> Maybe PaymentData
hp_payment_data :: !(Maybe PaymentData)
, HopPayload -> Maybe ByteString
hp_encrypted_data :: !(Maybe BS.ByteString)
, HopPayload -> Maybe Point
hp_current_path_key :: !(Maybe BOLT1.Point)
, HopPayload -> Maybe ByteString
hp_payment_metadata :: !(Maybe BS.ByteString)
, HopPayload -> Maybe MilliSatoshi
hp_total_amount_msat :: !(Maybe BOLT1.MilliSatoshi)
, :: !BOLT1.TlvStream
} deriving (HopPayload -> HopPayload -> Bool
(HopPayload -> HopPayload -> Bool)
-> (HopPayload -> HopPayload -> Bool) -> Eq HopPayload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HopPayload -> HopPayload -> Bool
== :: HopPayload -> HopPayload -> Bool
$c/= :: HopPayload -> HopPayload -> Bool
/= :: HopPayload -> HopPayload -> Bool
Eq, Int -> HopPayload -> ShowS
[HopPayload] -> ShowS
HopPayload -> String
(Int -> HopPayload -> ShowS)
-> (HopPayload -> String)
-> ([HopPayload] -> ShowS)
-> Show HopPayload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HopPayload -> ShowS
showsPrec :: Int -> HopPayload -> ShowS
$cshow :: HopPayload -> String
show :: HopPayload -> String
$cshowList :: [HopPayload] -> ShowS
showList :: [HopPayload] -> ShowS
Show, (forall x. HopPayload -> Rep HopPayload x)
-> (forall x. Rep HopPayload x -> HopPayload) -> Generic HopPayload
forall x. Rep HopPayload x -> HopPayload
forall x. HopPayload -> Rep HopPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HopPayload -> Rep HopPayload x
from :: forall x. HopPayload -> Rep HopPayload x
$cto :: forall x. Rep HopPayload x -> HopPayload
to :: forall x. Rep HopPayload x -> HopPayload
Generic)
instance NFData HopPayload
empty_hop_payload :: HopPayload
empty_hop_payload :: HopPayload
empty_hop_payload = Maybe MilliSatoshi
-> Maybe Word32
-> Maybe ShortChannelId
-> Maybe PaymentData
-> Maybe ByteString
-> Maybe Point
-> Maybe ByteString
-> Maybe MilliSatoshi
-> TlvStream
-> HopPayload
HopPayload
Maybe MilliSatoshi
forall a. Maybe a
Nothing Maybe Word32
forall a. Maybe a
Nothing Maybe ShortChannelId
forall a. Maybe a
Nothing Maybe PaymentData
forall a. Maybe a
Nothing Maybe ByteString
forall a. Maybe a
Nothing Maybe Point
forall a. Maybe a
Nothing Maybe ByteString
forall a. Maybe a
Nothing Maybe MilliSatoshi
forall a. Maybe a
Nothing
TlvStream
BOLT1.empty_tlv_stream
data PaymentData = PaymentData
{ PaymentData -> PaymentSecret
pd_payment_secret :: !PaymentSecret
, PaymentData -> MilliSatoshi
pd_total_msat :: !BOLT1.MilliSatoshi
} deriving (PaymentData -> PaymentData -> Bool
(PaymentData -> PaymentData -> Bool)
-> (PaymentData -> PaymentData -> Bool) -> Eq PaymentData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaymentData -> PaymentData -> Bool
== :: PaymentData -> PaymentData -> Bool
$c/= :: PaymentData -> PaymentData -> Bool
/= :: PaymentData -> PaymentData -> Bool
Eq, Int -> PaymentData -> ShowS
[PaymentData] -> ShowS
PaymentData -> String
(Int -> PaymentData -> ShowS)
-> (PaymentData -> String)
-> ([PaymentData] -> ShowS)
-> Show PaymentData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaymentData -> ShowS
showsPrec :: Int -> PaymentData -> ShowS
$cshow :: PaymentData -> String
show :: PaymentData -> String
$cshowList :: [PaymentData] -> ShowS
showList :: [PaymentData] -> ShowS
Show, (forall x. PaymentData -> Rep PaymentData x)
-> (forall x. Rep PaymentData x -> PaymentData)
-> Generic PaymentData
forall x. Rep PaymentData x -> PaymentData
forall x. PaymentData -> Rep PaymentData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PaymentData -> Rep PaymentData x
from :: forall x. PaymentData -> Rep PaymentData x
$cto :: forall x. Rep PaymentData x -> PaymentData
to :: forall x. Rep PaymentData x -> PaymentData
Generic)
instance NFData PaymentData
newtype PaymentSecret = PaymentSecret BS.ByteString
instance Eq PaymentSecret where
PaymentSecret ByteString
a == :: PaymentSecret -> PaymentSecret -> Bool
== PaymentSecret ByteString
b = ByteString -> ByteString -> Bool
P.ct_eq ByteString
a ByteString
b
instance Show PaymentSecret where
showsPrec :: Int -> PaymentSecret -> ShowS
showsPrec Int
d PaymentSecret
_ = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"PaymentSecret <redacted>"
instance NFData PaymentSecret where
rnf :: PaymentSecret -> ()
rnf (PaymentSecret ByteString
bs) = ByteString -> ()
forall a. NFData a => a -> ()
rnf ByteString
bs
payment_secret :: BS.ByteString -> Maybe PaymentSecret
payment_secret :: ByteString -> Maybe PaymentSecret
payment_secret ByteString
bs
| ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = PaymentSecret -> Maybe PaymentSecret
forall a. a -> Maybe a
Just (ByteString -> PaymentSecret
PaymentSecret ByteString
bs)
| Bool
otherwise = Maybe PaymentSecret
forall a. Maybe a
Nothing
{-# INLINE payment_secret #-}
un_payment_secret :: PaymentSecret -> BS.ByteString
un_payment_secret :: PaymentSecret -> ByteString
un_payment_secret (PaymentSecret ByteString
bs) = ByteString
bs
{-# INLINE un_payment_secret #-}
data BlindedPath = BlindedPath
{ BlindedPath -> Point
bp_first_node_id :: !BOLT1.Point
, BlindedPath -> Point
bp_first_path_key :: !BOLT1.Point
, BlindedPath -> [BlindedHop]
bp_hops :: ![BlindedHop]
} deriving (BlindedPath -> BlindedPath -> Bool
(BlindedPath -> BlindedPath -> Bool)
-> (BlindedPath -> BlindedPath -> Bool) -> Eq BlindedPath
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BlindedPath -> BlindedPath -> Bool
== :: BlindedPath -> BlindedPath -> Bool
$c/= :: BlindedPath -> BlindedPath -> Bool
/= :: BlindedPath -> BlindedPath -> Bool
Eq, Int -> BlindedPath -> ShowS
[BlindedPath] -> ShowS
BlindedPath -> String
(Int -> BlindedPath -> ShowS)
-> (BlindedPath -> String)
-> ([BlindedPath] -> ShowS)
-> Show BlindedPath
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BlindedPath -> ShowS
showsPrec :: Int -> BlindedPath -> ShowS
$cshow :: BlindedPath -> String
show :: BlindedPath -> String
$cshowList :: [BlindedPath] -> ShowS
showList :: [BlindedPath] -> ShowS
Show, (forall x. BlindedPath -> Rep BlindedPath x)
-> (forall x. Rep BlindedPath x -> BlindedPath)
-> Generic BlindedPath
forall x. Rep BlindedPath x -> BlindedPath
forall x. BlindedPath -> Rep BlindedPath x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BlindedPath -> Rep BlindedPath x
from :: forall x. BlindedPath -> Rep BlindedPath x
$cto :: forall x. Rep BlindedPath x -> BlindedPath
to :: forall x. Rep BlindedPath x -> BlindedPath
Generic)
instance NFData BlindedPath
data BlindedHop = BlindedHop
{ BlindedHop -> Point
bh_blinded_node_id :: !BOLT1.Point
, BlindedHop -> ByteString
bh_encrypted_data :: !BS.ByteString
} deriving (BlindedHop -> BlindedHop -> Bool
(BlindedHop -> BlindedHop -> Bool)
-> (BlindedHop -> BlindedHop -> Bool) -> Eq BlindedHop
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BlindedHop -> BlindedHop -> Bool
== :: BlindedHop -> BlindedHop -> Bool
$c/= :: BlindedHop -> BlindedHop -> Bool
/= :: BlindedHop -> BlindedHop -> Bool
Eq, Int -> BlindedHop -> ShowS
[BlindedHop] -> ShowS
BlindedHop -> String
(Int -> BlindedHop -> ShowS)
-> (BlindedHop -> String)
-> ([BlindedHop] -> ShowS)
-> Show BlindedHop
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BlindedHop -> ShowS
showsPrec :: Int -> BlindedHop -> ShowS
$cshow :: BlindedHop -> String
show :: BlindedHop -> String
$cshowList :: [BlindedHop] -> ShowS
showList :: [BlindedHop] -> ShowS
Show, (forall x. BlindedHop -> Rep BlindedHop x)
-> (forall x. Rep BlindedHop x -> BlindedHop) -> Generic BlindedHop
forall x. Rep BlindedHop x -> BlindedHop
forall x. BlindedHop -> Rep BlindedHop x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BlindedHop -> Rep BlindedHop x
from :: forall x. BlindedHop -> Rep BlindedHop x
$cto :: forall x. Rep BlindedHop x -> BlindedHop
to :: forall x. Rep BlindedHop x -> BlindedHop
Generic)
instance NFData BlindedHop
data BlindedHopData = BlindedHopData
{ BlindedHopData -> Maybe ByteString
bhd_padding :: !(Maybe BS.ByteString)
, BlindedHopData -> Maybe ShortChannelId
bhd_short_channel_id :: !(Maybe BOLT1.ShortChannelId)
, BlindedHopData -> Maybe Point
bhd_next_node_id :: !(Maybe BOLT1.Point)
, BlindedHopData -> Maybe ByteString
bhd_path_id :: !(Maybe BS.ByteString)
, BlindedHopData -> Maybe Point
bhd_next_path_key_override :: !(Maybe BOLT1.Point)
, BlindedHopData -> Maybe PaymentRelay
bhd_payment_relay :: !(Maybe PaymentRelay)
, BlindedHopData -> Maybe PaymentConstraints
bhd_payment_constraints :: !(Maybe PaymentConstraints)
, BlindedHopData -> Maybe FeatureVector
bhd_allowed_features :: !(Maybe BOLT9.FeatureVector)
, :: !BOLT1.TlvStream
} deriving (BlindedHopData -> BlindedHopData -> Bool
(BlindedHopData -> BlindedHopData -> Bool)
-> (BlindedHopData -> BlindedHopData -> Bool) -> Eq BlindedHopData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BlindedHopData -> BlindedHopData -> Bool
== :: BlindedHopData -> BlindedHopData -> Bool
$c/= :: BlindedHopData -> BlindedHopData -> Bool
/= :: BlindedHopData -> BlindedHopData -> Bool
Eq, Int -> BlindedHopData -> ShowS
[BlindedHopData] -> ShowS
BlindedHopData -> String
(Int -> BlindedHopData -> ShowS)
-> (BlindedHopData -> String)
-> ([BlindedHopData] -> ShowS)
-> Show BlindedHopData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BlindedHopData -> ShowS
showsPrec :: Int -> BlindedHopData -> ShowS
$cshow :: BlindedHopData -> String
show :: BlindedHopData -> String
$cshowList :: [BlindedHopData] -> ShowS
showList :: [BlindedHopData] -> ShowS
Show, (forall x. BlindedHopData -> Rep BlindedHopData x)
-> (forall x. Rep BlindedHopData x -> BlindedHopData)
-> Generic BlindedHopData
forall x. Rep BlindedHopData x -> BlindedHopData
forall x. BlindedHopData -> Rep BlindedHopData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BlindedHopData -> Rep BlindedHopData x
from :: forall x. BlindedHopData -> Rep BlindedHopData x
$cto :: forall x. Rep BlindedHopData x -> BlindedHopData
to :: forall x. Rep BlindedHopData x -> BlindedHopData
Generic)
instance NFData BlindedHopData
empty_blinded_hop_data :: BlindedHopData
empty_blinded_hop_data :: BlindedHopData
empty_blinded_hop_data = Maybe ByteString
-> Maybe ShortChannelId
-> Maybe Point
-> Maybe ByteString
-> Maybe Point
-> Maybe PaymentRelay
-> Maybe PaymentConstraints
-> Maybe FeatureVector
-> TlvStream
-> BlindedHopData
BlindedHopData
Maybe ByteString
forall a. Maybe a
Nothing Maybe ShortChannelId
forall a. Maybe a
Nothing Maybe Point
forall a. Maybe a
Nothing Maybe ByteString
forall a. Maybe a
Nothing Maybe Point
forall a. Maybe a
Nothing Maybe PaymentRelay
forall a. Maybe a
Nothing Maybe PaymentConstraints
forall a. Maybe a
Nothing Maybe FeatureVector
forall a. Maybe a
Nothing
TlvStream
BOLT1.empty_tlv_stream
data PaymentRelay = PaymentRelay
{ PaymentRelay -> Word16
pr_cltv_expiry_delta :: {-# UNPACK #-} !Word16
, PaymentRelay -> Word32
pr_fee_proportional_millionths :: {-# UNPACK #-} !Word32
, PaymentRelay -> Word32
pr_fee_base_msat :: {-# UNPACK #-} !Word32
} deriving (PaymentRelay -> PaymentRelay -> Bool
(PaymentRelay -> PaymentRelay -> Bool)
-> (PaymentRelay -> PaymentRelay -> Bool) -> Eq PaymentRelay
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaymentRelay -> PaymentRelay -> Bool
== :: PaymentRelay -> PaymentRelay -> Bool
$c/= :: PaymentRelay -> PaymentRelay -> Bool
/= :: PaymentRelay -> PaymentRelay -> Bool
Eq, Int -> PaymentRelay -> ShowS
[PaymentRelay] -> ShowS
PaymentRelay -> String
(Int -> PaymentRelay -> ShowS)
-> (PaymentRelay -> String)
-> ([PaymentRelay] -> ShowS)
-> Show PaymentRelay
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaymentRelay -> ShowS
showsPrec :: Int -> PaymentRelay -> ShowS
$cshow :: PaymentRelay -> String
show :: PaymentRelay -> String
$cshowList :: [PaymentRelay] -> ShowS
showList :: [PaymentRelay] -> ShowS
Show, (forall x. PaymentRelay -> Rep PaymentRelay x)
-> (forall x. Rep PaymentRelay x -> PaymentRelay)
-> Generic PaymentRelay
forall x. Rep PaymentRelay x -> PaymentRelay
forall x. PaymentRelay -> Rep PaymentRelay x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PaymentRelay -> Rep PaymentRelay x
from :: forall x. PaymentRelay -> Rep PaymentRelay x
$cto :: forall x. Rep PaymentRelay x -> PaymentRelay
to :: forall x. Rep PaymentRelay x -> PaymentRelay
Generic)
instance NFData PaymentRelay
data PaymentConstraints = PaymentConstraints
{ PaymentConstraints -> Word32
pc_max_cltv_expiry :: {-# UNPACK #-} !Word32
, PaymentConstraints -> MilliSatoshi
pc_htlc_minimum_msat :: !BOLT1.MilliSatoshi
} deriving (PaymentConstraints -> PaymentConstraints -> Bool
(PaymentConstraints -> PaymentConstraints -> Bool)
-> (PaymentConstraints -> PaymentConstraints -> Bool)
-> Eq PaymentConstraints
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaymentConstraints -> PaymentConstraints -> Bool
== :: PaymentConstraints -> PaymentConstraints -> Bool
$c/= :: PaymentConstraints -> PaymentConstraints -> Bool
/= :: PaymentConstraints -> PaymentConstraints -> Bool
Eq, Int -> PaymentConstraints -> ShowS
[PaymentConstraints] -> ShowS
PaymentConstraints -> String
(Int -> PaymentConstraints -> ShowS)
-> (PaymentConstraints -> String)
-> ([PaymentConstraints] -> ShowS)
-> Show PaymentConstraints
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaymentConstraints -> ShowS
showsPrec :: Int -> PaymentConstraints -> ShowS
$cshow :: PaymentConstraints -> String
show :: PaymentConstraints -> String
$cshowList :: [PaymentConstraints] -> ShowS
showList :: [PaymentConstraints] -> ShowS
Show, (forall x. PaymentConstraints -> Rep PaymentConstraints x)
-> (forall x. Rep PaymentConstraints x -> PaymentConstraints)
-> Generic PaymentConstraints
forall x. Rep PaymentConstraints x -> PaymentConstraints
forall x. PaymentConstraints -> Rep PaymentConstraints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PaymentConstraints -> Rep PaymentConstraints x
from :: forall x. PaymentConstraints -> Rep PaymentConstraints x
$cto :: forall x. Rep PaymentConstraints x -> PaymentConstraints
to :: forall x. Rep PaymentConstraints x -> PaymentConstraints
Generic)
instance NFData PaymentConstraints
data BlindedInfo = BlindedInfo
{ BlindedInfo -> BlindedHopData
bi_data :: !BlindedHopData
, BlindedInfo -> Point
bi_next_path_key :: !BOLT1.Point
} deriving (BlindedInfo -> BlindedInfo -> Bool
(BlindedInfo -> BlindedInfo -> Bool)
-> (BlindedInfo -> BlindedInfo -> Bool) -> Eq BlindedInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BlindedInfo -> BlindedInfo -> Bool
== :: BlindedInfo -> BlindedInfo -> Bool
$c/= :: BlindedInfo -> BlindedInfo -> Bool
/= :: BlindedInfo -> BlindedInfo -> Bool
Eq, Int -> BlindedInfo -> ShowS
[BlindedInfo] -> ShowS
BlindedInfo -> String
(Int -> BlindedInfo -> ShowS)
-> (BlindedInfo -> String)
-> ([BlindedInfo] -> ShowS)
-> Show BlindedInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BlindedInfo -> ShowS
showsPrec :: Int -> BlindedInfo -> ShowS
$cshow :: BlindedInfo -> String
show :: BlindedInfo -> String
$cshowList :: [BlindedInfo] -> ShowS
showList :: [BlindedInfo] -> ShowS
Show, (forall x. BlindedInfo -> Rep BlindedInfo x)
-> (forall x. Rep BlindedInfo x -> BlindedInfo)
-> Generic BlindedInfo
forall x. Rep BlindedInfo x -> BlindedInfo
forall x. BlindedInfo -> Rep BlindedInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BlindedInfo -> Rep BlindedInfo x
from :: forall x. BlindedInfo -> Rep BlindedInfo x
$cto :: forall x. Rep BlindedInfo x -> BlindedInfo
to :: forall x. Rep BlindedInfo x -> BlindedInfo
Generic)
instance NFData BlindedInfo
data FailureMessage = FailureMessage
{ FailureMessage -> Failure
fm_failure :: !Failure
, FailureMessage -> TlvStream
fm_tlvs :: !BOLT1.TlvStream
} deriving (FailureMessage -> FailureMessage -> Bool
(FailureMessage -> FailureMessage -> Bool)
-> (FailureMessage -> FailureMessage -> Bool) -> Eq FailureMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FailureMessage -> FailureMessage -> Bool
== :: FailureMessage -> FailureMessage -> Bool
$c/= :: FailureMessage -> FailureMessage -> Bool
/= :: FailureMessage -> FailureMessage -> Bool
Eq, Int -> FailureMessage -> ShowS
[FailureMessage] -> ShowS
FailureMessage -> String
(Int -> FailureMessage -> ShowS)
-> (FailureMessage -> String)
-> ([FailureMessage] -> ShowS)
-> Show FailureMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FailureMessage -> ShowS
showsPrec :: Int -> FailureMessage -> ShowS
$cshow :: FailureMessage -> String
show :: FailureMessage -> String
$cshowList :: [FailureMessage] -> ShowS
showList :: [FailureMessage] -> ShowS
Show, (forall x. FailureMessage -> Rep FailureMessage x)
-> (forall x. Rep FailureMessage x -> FailureMessage)
-> Generic FailureMessage
forall x. Rep FailureMessage x -> FailureMessage
forall x. FailureMessage -> Rep FailureMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FailureMessage -> Rep FailureMessage x
from :: forall x. FailureMessage -> Rep FailureMessage x
$cto :: forall x. Rep FailureMessage x -> FailureMessage
to :: forall x. Rep FailureMessage x -> FailureMessage
Generic)
instance NFData FailureMessage
data Failure
= TemporaryNodeFailure
| PermanentNodeFailure
| RequiredNodeFeatureMissing
| InvalidOnionVersion !OnionHash
| InvalidOnionHmac !OnionHash
| InvalidOnionKey !OnionHash
| TemporaryChannelFailure !BS.ByteString
| PermanentChannelFailure
| RequiredChannelFeatureMissing
| UnknownNextPeer
| AmountBelowMinimum !BOLT1.MilliSatoshi !BS.ByteString
| FeeInsufficient !BOLT1.MilliSatoshi !BS.ByteString
| IncorrectCltvExpiry {-# UNPACK #-} !Word32 !BS.ByteString
| ExpiryTooSoon !BS.ByteString
| IncorrectOrUnknownPaymentDetails !BOLT1.MilliSatoshi
{-# UNPACK #-} !Word32
| FinalIncorrectCltvExpiry {-# UNPACK #-} !Word32
| FinalIncorrectHtlcAmount !BOLT1.MilliSatoshi
| ChannelDisabled {-# UNPACK #-} !Word16 !BS.ByteString
| ExpiryTooFar
| InvalidOnionPayload !(Maybe (Word64, Word16))
| MppTimeout
| InvalidOnionBlinding !OnionHash
| UnknownFailure {-# UNPACK #-} !Word16 !BS.ByteString
deriving (Failure -> Failure -> Bool
(Failure -> Failure -> Bool)
-> (Failure -> Failure -> Bool) -> Eq Failure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Failure -> Failure -> Bool
== :: Failure -> Failure -> Bool
$c/= :: Failure -> Failure -> Bool
/= :: Failure -> Failure -> Bool
Eq, Int -> Failure -> ShowS
[Failure] -> ShowS
Failure -> String
(Int -> Failure -> ShowS)
-> (Failure -> String) -> ([Failure] -> ShowS) -> Show Failure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Failure -> ShowS
showsPrec :: Int -> Failure -> ShowS
$cshow :: Failure -> String
show :: Failure -> String
$cshowList :: [Failure] -> ShowS
showList :: [Failure] -> ShowS
Show, (forall x. Failure -> Rep Failure x)
-> (forall x. Rep Failure x -> Failure) -> Generic Failure
forall x. Rep Failure x -> Failure
forall x. Failure -> Rep Failure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Failure -> Rep Failure x
from :: forall x. Failure -> Rep Failure x
$cto :: forall x. Rep Failure x -> Failure
to :: forall x. Rep Failure x -> Failure
Generic)
instance NFData Failure
newtype OnionHash = OnionHash BS.ByteString
deriving (OnionHash -> OnionHash -> Bool
(OnionHash -> OnionHash -> Bool)
-> (OnionHash -> OnionHash -> Bool) -> Eq OnionHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OnionHash -> OnionHash -> Bool
== :: OnionHash -> OnionHash -> Bool
$c/= :: OnionHash -> OnionHash -> Bool
/= :: OnionHash -> OnionHash -> Bool
Eq, Int -> OnionHash -> ShowS
[OnionHash] -> ShowS
OnionHash -> String
(Int -> OnionHash -> ShowS)
-> (OnionHash -> String)
-> ([OnionHash] -> ShowS)
-> Show OnionHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OnionHash -> ShowS
showsPrec :: Int -> OnionHash -> ShowS
$cshow :: OnionHash -> String
show :: OnionHash -> String
$cshowList :: [OnionHash] -> ShowS
showList :: [OnionHash] -> ShowS
Show, (forall x. OnionHash -> Rep OnionHash x)
-> (forall x. Rep OnionHash x -> OnionHash) -> Generic OnionHash
forall x. Rep OnionHash x -> OnionHash
forall x. OnionHash -> Rep OnionHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. OnionHash -> Rep OnionHash x
from :: forall x. OnionHash -> Rep OnionHash x
$cto :: forall x. Rep OnionHash x -> OnionHash
to :: forall x. Rep OnionHash x -> OnionHash
Generic)
instance NFData OnionHash
onion_hash :: BS.ByteString -> Maybe OnionHash
onion_hash :: ByteString -> Maybe OnionHash
onion_hash ByteString
bs
| ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = OnionHash -> Maybe OnionHash
forall a. a -> Maybe a
Just (ByteString -> OnionHash
OnionHash ByteString
bs)
| Bool
otherwise = Maybe OnionHash
forall a. Maybe a
Nothing
{-# INLINE onion_hash #-}
un_onion_hash :: OnionHash -> BS.ByteString
un_onion_hash :: OnionHash -> ByteString
un_onion_hash (OnionHash ByteString
bs) = ByteString
bs
{-# INLINE un_onion_hash #-}
failure_code :: Failure -> Word16
failure_code :: Failure -> Word16
failure_code Failure
f = case Failure
f of
Failure
TemporaryNodeFailure -> Word16
0x2002
Failure
PermanentNodeFailure -> Word16
0x6002
Failure
RequiredNodeFeatureMissing -> Word16
0x6003
InvalidOnionVersion OnionHash
_ -> Word16
0xc004
InvalidOnionHmac OnionHash
_ -> Word16
0xc005
InvalidOnionKey OnionHash
_ -> Word16
0xc006
TemporaryChannelFailure ByteString
_ -> Word16
0x1007
Failure
PermanentChannelFailure -> Word16
0x4008
Failure
RequiredChannelFeatureMissing -> Word16
0x4009
Failure
UnknownNextPeer -> Word16
0x400a
AmountBelowMinimum MilliSatoshi
_ ByteString
_ -> Word16
0x100b
FeeInsufficient MilliSatoshi
_ ByteString
_ -> Word16
0x100c
IncorrectCltvExpiry Word32
_ ByteString
_ -> Word16
0x100d
ExpiryTooSoon ByteString
_ -> Word16
0x100e
IncorrectOrUnknownPaymentDetails MilliSatoshi
_ Word32
_ -> Word16
0x400f
FinalIncorrectCltvExpiry Word32
_ -> Word16
0x0012
FinalIncorrectHtlcAmount MilliSatoshi
_ -> Word16
0x0013
ChannelDisabled Word16
_ ByteString
_ -> Word16
0x1014
Failure
ExpiryTooFar -> Word16
0x0015
InvalidOnionPayload Maybe (Word64, Word16)
_ -> Word16
0x4016
Failure
MppTimeout -> Word16
0x0017
InvalidOnionBlinding OnionHash
_ -> Word16
0xc018
UnknownFailure Word16
c ByteString
_ -> Word16
c
is_badonion :: Failure -> Bool
is_badonion :: Failure -> Bool
is_badonion Failure
f = Failure -> Word16
failure_code Failure
f Word16 -> Word16 -> Word16
forall a. Bits a => a -> a -> a
.&. Word16
0x8000 Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word16
0
{-# INLINE is_badonion #-}
is_perm :: Failure -> Bool
is_perm :: Failure -> Bool
is_perm Failure
f = Failure -> Word16
failure_code Failure
f Word16 -> Word16 -> Word16
forall a. Bits a => a -> a -> a
.&. Word16
0x4000 Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word16
0
{-# INLINE is_perm #-}
is_node :: Failure -> Bool
is_node :: Failure -> Bool
is_node Failure
f = Failure -> Word16
failure_code Failure
f Word16 -> Word16 -> Word16
forall a. Bits a => a -> a -> a
.&. Word16
0x2000 Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word16
0
{-# INLINE is_node #-}
is_update :: Failure -> Bool
is_update :: Failure -> Bool
is_update Failure
f = Failure -> Word16
failure_code Failure
f Word16 -> Word16 -> Word16
forall a. Bits a => a -> a -> a
.&. Word16
0x1000 Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word16
0
{-# INLINE is_update #-}
data DecodeError
= InvalidLength
| InvalidPoint
| InvalidTlvStream !BOLT1.TlvError
| InvalidTlvValue {-# UNPACK #-} !Word64
| InvalidFailureData {-# UNPACK #-} !Word16
deriving (DecodeError -> DecodeError -> Bool
(DecodeError -> DecodeError -> Bool)
-> (DecodeError -> DecodeError -> Bool) -> Eq DecodeError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DecodeError -> DecodeError -> Bool
== :: DecodeError -> DecodeError -> Bool
$c/= :: DecodeError -> DecodeError -> Bool
/= :: DecodeError -> DecodeError -> Bool
Eq, Int -> DecodeError -> ShowS
[DecodeError] -> ShowS
DecodeError -> String
(Int -> DecodeError -> ShowS)
-> (DecodeError -> String)
-> ([DecodeError] -> ShowS)
-> Show DecodeError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DecodeError -> ShowS
showsPrec :: Int -> DecodeError -> ShowS
$cshow :: DecodeError -> String
show :: DecodeError -> String
$cshowList :: [DecodeError] -> ShowS
showList :: [DecodeError] -> ShowS
Show, (forall x. DecodeError -> Rep DecodeError x)
-> (forall x. Rep DecodeError x -> DecodeError)
-> Generic DecodeError
forall x. Rep DecodeError x -> DecodeError
forall x. DecodeError -> Rep DecodeError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DecodeError -> Rep DecodeError x
from :: forall x. DecodeError -> Rep DecodeError x
$cto :: forall x. Rep DecodeError x -> DecodeError
to :: forall x. Rep DecodeError x -> DecodeError
Generic)
instance NFData DecodeError
data EncodeError
= ConflictingTlv
| FieldTooLong
deriving (EncodeError -> EncodeError -> Bool
(EncodeError -> EncodeError -> Bool)
-> (EncodeError -> EncodeError -> Bool) -> Eq EncodeError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EncodeError -> EncodeError -> Bool
== :: EncodeError -> EncodeError -> Bool
$c/= :: EncodeError -> EncodeError -> Bool
/= :: EncodeError -> EncodeError -> Bool
Eq, Int -> EncodeError -> ShowS
[EncodeError] -> ShowS
EncodeError -> String
(Int -> EncodeError -> ShowS)
-> (EncodeError -> String)
-> ([EncodeError] -> ShowS)
-> Show EncodeError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EncodeError -> ShowS
showsPrec :: Int -> EncodeError -> ShowS
$cshow :: EncodeError -> String
show :: EncodeError -> String
$cshowList :: [EncodeError] -> ShowS
showList :: [EncodeError] -> ShowS
Show, (forall x. EncodeError -> Rep EncodeError x)
-> (forall x. Rep EncodeError x -> EncodeError)
-> Generic EncodeError
forall x. Rep EncodeError x -> EncodeError
forall x. EncodeError -> Rep EncodeError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. EncodeError -> Rep EncodeError x
from :: forall x. EncodeError -> Rep EncodeError x
$cto :: forall x. Rep EncodeError x -> EncodeError
to :: forall x. Rep EncodeError x -> EncodeError
Generic)
instance NFData EncodeError
data ProcessError
= InvalidVersion {-# UNPACK #-} !Word8
| InvalidPublicKey
| HmacMismatch
| InvalidPayloadLength
| InvalidPayload !DecodeError
| InvalidPathKey
| UnexpectedPathKey
| MissingPathKey
| InvalidRecipientData
deriving (ProcessError -> ProcessError -> Bool
(ProcessError -> ProcessError -> Bool)
-> (ProcessError -> ProcessError -> Bool) -> Eq ProcessError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProcessError -> ProcessError -> Bool
== :: ProcessError -> ProcessError -> Bool
$c/= :: ProcessError -> ProcessError -> Bool
/= :: ProcessError -> ProcessError -> Bool
Eq, Int -> ProcessError -> ShowS
[ProcessError] -> ShowS
ProcessError -> String
(Int -> ProcessError -> ShowS)
-> (ProcessError -> String)
-> ([ProcessError] -> ShowS)
-> Show ProcessError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProcessError -> ShowS
showsPrec :: Int -> ProcessError -> ShowS
$cshow :: ProcessError -> String
show :: ProcessError -> String
$cshowList :: [ProcessError] -> ShowS
showList :: [ProcessError] -> ShowS
Show, (forall x. ProcessError -> Rep ProcessError x)
-> (forall x. Rep ProcessError x -> ProcessError)
-> Generic ProcessError
forall x. Rep ProcessError x -> ProcessError
forall x. ProcessError -> Rep ProcessError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ProcessError -> Rep ProcessError x
from :: forall x. ProcessError -> Rep ProcessError x
$cto :: forall x. Rep ProcessError x -> ProcessError
to :: forall x. Rep ProcessError x -> ProcessError
Generic)
instance NFData ProcessError