{-# OPTIONS_HADDOCK prune #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

-- |
-- Module: Lightning.Protocol.BOLT3.Types
-- Copyright: (c) 2025 Jared Tobin
-- License: MIT
-- Maintainer: Jared Tobin <jared@ppad.tech>
--
-- Core types for BOLT #3 transaction and script formats.

module Lightning.Protocol.BOLT3.Types (
    -- * Monetary amounts
    Satoshi(..)
  , MilliSatoshi(..)
  , msat_to_sat
  , sat_to_msat

    -- * Keys and points
  , Pubkey(..)
  , pubkey
  , Seckey(..)
  , seckey
  , Point(..)
  , point

    -- * Hashes
  , PaymentHash(..)
  , payment_hash
  , PaymentPreimage(..)
  , payment_preimage

    -- * Transaction primitives
  , TxId(..)
  , txid
  , Outpoint(..)
  , Sequence(..)
  , Locktime(..)

    -- * Channel parameters
  , CommitmentNumber(..)
  , commitment_number
  , ToSelfDelay(..)
  , CltvExpiry(..)
  , DustLimit(..)
  , FeeratePerKw(..)

    -- * HTLC types
  , HTLC(..)
  , HTLCDirection(..)

    -- * Basepoints
  , Basepoints(..)
  , PerCommitmentPoint(..)
  , PerCommitmentSecret(..)
  , per_commitment_secret
  , RevocationBasepoint(..)
  , PaymentBasepoint(..)
  , DelayedPaymentBasepoint(..)
  , HtlcBasepoint(..)

    -- * Derived keys
  , LocalPubkey(..)
  , RemotePubkey(..)
  , LocalDelayedPubkey(..)
  , RemoteDelayedPubkey(..)
  , LocalHtlcPubkey(..)
  , RemoteHtlcPubkey(..)
  , RevocationPubkey(..)
  , FundingPubkey(..)

    -- * Script and witness
  , Script(..)
  , Witness(..)

    -- * Channel options
  , ChannelFeatures(..)
  , has_anchors

    -- * Transaction weights (constants)
  , commitment_weight_no_anchors
  , commitment_weight_anchors
  , htlc_timeout_weight_no_anchors
  , htlc_timeout_weight_anchors
  , htlc_success_weight_no_anchors
  , htlc_success_weight_anchors
  , htlc_output_weight

    -- * Dust thresholds (constants)
  , dust_p2pkh
  , dust_p2sh
  , dust_p2wpkh
  , dust_p2wsh
  , anchor_output_value
  ) where

import Data.Word (Word16, Word32, Word64)
import qualified Data.ByteString as BS
import GHC.Generics (Generic)

-- monetary amounts ------------------------------------------------------------

-- | Amount in satoshis.
newtype Satoshi = Satoshi { Satoshi -> Word64
unSatoshi :: Word64 }
  deriving (Satoshi -> Satoshi -> Bool
(Satoshi -> Satoshi -> Bool)
-> (Satoshi -> Satoshi -> Bool) -> Eq Satoshi
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Satoshi -> Satoshi -> Bool
== :: Satoshi -> Satoshi -> Bool
$c/= :: Satoshi -> Satoshi -> Bool
/= :: Satoshi -> Satoshi -> Bool
Eq, Eq Satoshi
Eq Satoshi =>
(Satoshi -> Satoshi -> Ordering)
-> (Satoshi -> Satoshi -> Bool)
-> (Satoshi -> Satoshi -> Bool)
-> (Satoshi -> Satoshi -> Bool)
-> (Satoshi -> Satoshi -> Bool)
-> (Satoshi -> Satoshi -> Satoshi)
-> (Satoshi -> Satoshi -> Satoshi)
-> Ord Satoshi
Satoshi -> Satoshi -> Bool
Satoshi -> Satoshi -> Ordering
Satoshi -> Satoshi -> Satoshi
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Satoshi -> Satoshi -> Ordering
compare :: Satoshi -> Satoshi -> Ordering
$c< :: Satoshi -> Satoshi -> Bool
< :: Satoshi -> Satoshi -> Bool
$c<= :: Satoshi -> Satoshi -> Bool
<= :: Satoshi -> Satoshi -> Bool
$c> :: Satoshi -> Satoshi -> Bool
> :: Satoshi -> Satoshi -> Bool
$c>= :: Satoshi -> Satoshi -> Bool
>= :: Satoshi -> Satoshi -> Bool
$cmax :: Satoshi -> Satoshi -> Satoshi
max :: Satoshi -> Satoshi -> Satoshi
$cmin :: Satoshi -> Satoshi -> Satoshi
min :: Satoshi -> Satoshi -> Satoshi
Ord, Int -> Satoshi -> ShowS
[Satoshi] -> ShowS
Satoshi -> String
(Int -> Satoshi -> ShowS)
-> (Satoshi -> String) -> ([Satoshi] -> ShowS) -> Show Satoshi
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Satoshi -> ShowS
showsPrec :: Int -> Satoshi -> ShowS
$cshow :: Satoshi -> String
show :: Satoshi -> String
$cshowList :: [Satoshi] -> ShowS
showList :: [Satoshi] -> ShowS
Show, (forall x. Satoshi -> Rep Satoshi x)
-> (forall x. Rep Satoshi x -> Satoshi) -> Generic Satoshi
forall x. Rep Satoshi x -> Satoshi
forall x. Satoshi -> Rep Satoshi x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Satoshi -> Rep Satoshi x
from :: forall x. Satoshi -> Rep Satoshi x
$cto :: forall x. Rep Satoshi x -> Satoshi
to :: forall x. Rep Satoshi x -> Satoshi
Generic, Integer -> Satoshi
Satoshi -> Satoshi
Satoshi -> Satoshi -> Satoshi
(Satoshi -> Satoshi -> Satoshi)
-> (Satoshi -> Satoshi -> Satoshi)
-> (Satoshi -> Satoshi -> Satoshi)
-> (Satoshi -> Satoshi)
-> (Satoshi -> Satoshi)
-> (Satoshi -> Satoshi)
-> (Integer -> Satoshi)
-> Num Satoshi
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: Satoshi -> Satoshi -> Satoshi
+ :: Satoshi -> Satoshi -> Satoshi
$c- :: Satoshi -> Satoshi -> Satoshi
- :: Satoshi -> Satoshi -> Satoshi
$c* :: Satoshi -> Satoshi -> Satoshi
* :: Satoshi -> Satoshi -> Satoshi
$cnegate :: Satoshi -> Satoshi
negate :: Satoshi -> Satoshi
$cabs :: Satoshi -> Satoshi
abs :: Satoshi -> Satoshi
$csignum :: Satoshi -> Satoshi
signum :: Satoshi -> Satoshi
$cfromInteger :: Integer -> Satoshi
fromInteger :: Integer -> Satoshi
Num)

-- | Amount in millisatoshis.
newtype MilliSatoshi = MilliSatoshi { MilliSatoshi -> Word64
unMilliSatoshi :: Word64 }
  deriving (MilliSatoshi -> MilliSatoshi -> Bool
(MilliSatoshi -> MilliSatoshi -> Bool)
-> (MilliSatoshi -> MilliSatoshi -> Bool) -> Eq MilliSatoshi
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MilliSatoshi -> MilliSatoshi -> Bool
== :: MilliSatoshi -> MilliSatoshi -> Bool
$c/= :: MilliSatoshi -> MilliSatoshi -> Bool
/= :: MilliSatoshi -> MilliSatoshi -> Bool
Eq, Eq MilliSatoshi
Eq MilliSatoshi =>
(MilliSatoshi -> MilliSatoshi -> Ordering)
-> (MilliSatoshi -> MilliSatoshi -> Bool)
-> (MilliSatoshi -> MilliSatoshi -> Bool)
-> (MilliSatoshi -> MilliSatoshi -> Bool)
-> (MilliSatoshi -> MilliSatoshi -> Bool)
-> (MilliSatoshi -> MilliSatoshi -> MilliSatoshi)
-> (MilliSatoshi -> MilliSatoshi -> MilliSatoshi)
-> Ord MilliSatoshi
MilliSatoshi -> MilliSatoshi -> Bool
MilliSatoshi -> MilliSatoshi -> Ordering
MilliSatoshi -> MilliSatoshi -> MilliSatoshi
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: MilliSatoshi -> MilliSatoshi -> Ordering
compare :: MilliSatoshi -> MilliSatoshi -> Ordering
$c< :: MilliSatoshi -> MilliSatoshi -> Bool
< :: MilliSatoshi -> MilliSatoshi -> Bool
$c<= :: MilliSatoshi -> MilliSatoshi -> Bool
<= :: MilliSatoshi -> MilliSatoshi -> Bool
$c> :: MilliSatoshi -> MilliSatoshi -> Bool
> :: MilliSatoshi -> MilliSatoshi -> Bool
$c>= :: MilliSatoshi -> MilliSatoshi -> Bool
>= :: MilliSatoshi -> MilliSatoshi -> Bool
$cmax :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
max :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
$cmin :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
min :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
Ord, Int -> MilliSatoshi -> ShowS
[MilliSatoshi] -> ShowS
MilliSatoshi -> String
(Int -> MilliSatoshi -> ShowS)
-> (MilliSatoshi -> String)
-> ([MilliSatoshi] -> ShowS)
-> Show MilliSatoshi
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MilliSatoshi -> ShowS
showsPrec :: Int -> MilliSatoshi -> ShowS
$cshow :: MilliSatoshi -> String
show :: MilliSatoshi -> String
$cshowList :: [MilliSatoshi] -> ShowS
showList :: [MilliSatoshi] -> ShowS
Show, (forall x. MilliSatoshi -> Rep MilliSatoshi x)
-> (forall x. Rep MilliSatoshi x -> MilliSatoshi)
-> Generic MilliSatoshi
forall x. Rep MilliSatoshi x -> MilliSatoshi
forall x. MilliSatoshi -> Rep MilliSatoshi x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MilliSatoshi -> Rep MilliSatoshi x
from :: forall x. MilliSatoshi -> Rep MilliSatoshi x
$cto :: forall x. Rep MilliSatoshi x -> MilliSatoshi
to :: forall x. Rep MilliSatoshi x -> MilliSatoshi
Generic, Integer -> MilliSatoshi
MilliSatoshi -> MilliSatoshi
MilliSatoshi -> MilliSatoshi -> MilliSatoshi
(MilliSatoshi -> MilliSatoshi -> MilliSatoshi)
-> (MilliSatoshi -> MilliSatoshi -> MilliSatoshi)
-> (MilliSatoshi -> MilliSatoshi -> MilliSatoshi)
-> (MilliSatoshi -> MilliSatoshi)
-> (MilliSatoshi -> MilliSatoshi)
-> (MilliSatoshi -> MilliSatoshi)
-> (Integer -> MilliSatoshi)
-> Num MilliSatoshi
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
+ :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
$c- :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
- :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
$c* :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
* :: MilliSatoshi -> MilliSatoshi -> MilliSatoshi
$cnegate :: MilliSatoshi -> MilliSatoshi
negate :: MilliSatoshi -> MilliSatoshi
$cabs :: MilliSatoshi -> MilliSatoshi
abs :: MilliSatoshi -> MilliSatoshi
$csignum :: MilliSatoshi -> MilliSatoshi
signum :: MilliSatoshi -> MilliSatoshi
$cfromInteger :: Integer -> MilliSatoshi
fromInteger :: Integer -> MilliSatoshi
Num)

-- | Convert millisatoshis to satoshis (rounds down).
msat_to_sat :: MilliSatoshi -> Satoshi
msat_to_sat :: MilliSatoshi -> Satoshi
msat_to_sat (MilliSatoshi Word64
m) = Word64 -> Satoshi
Satoshi (Word64
m Word64 -> Word64 -> Word64
forall a. Integral a => a -> a -> a
`div` Word64
1000)
{-# INLINE msat_to_sat #-}

-- | Convert satoshis to millisatoshis.
sat_to_msat :: Satoshi -> MilliSatoshi
sat_to_msat :: Satoshi -> MilliSatoshi
sat_to_msat (Satoshi Word64
s) = Word64 -> MilliSatoshi
MilliSatoshi (Word64
s Word64 -> Word64 -> Word64
forall a. Num a => a -> a -> a
* Word64
1000)
{-# INLINE sat_to_msat #-}

-- keys and points -------------------------------------------------------------

-- | Compressed public key (33 bytes).
newtype Pubkey = Pubkey { Pubkey -> ByteString
unPubkey :: BS.ByteString }
  deriving (Pubkey -> Pubkey -> Bool
(Pubkey -> Pubkey -> Bool)
-> (Pubkey -> Pubkey -> Bool) -> Eq Pubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Pubkey -> Pubkey -> Bool
== :: Pubkey -> Pubkey -> Bool
$c/= :: Pubkey -> Pubkey -> Bool
/= :: Pubkey -> Pubkey -> Bool
Eq, Eq Pubkey
Eq Pubkey =>
(Pubkey -> Pubkey -> Ordering)
-> (Pubkey -> Pubkey -> Bool)
-> (Pubkey -> Pubkey -> Bool)
-> (Pubkey -> Pubkey -> Bool)
-> (Pubkey -> Pubkey -> Bool)
-> (Pubkey -> Pubkey -> Pubkey)
-> (Pubkey -> Pubkey -> Pubkey)
-> Ord Pubkey
Pubkey -> Pubkey -> Bool
Pubkey -> Pubkey -> Ordering
Pubkey -> Pubkey -> Pubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Pubkey -> Pubkey -> Ordering
compare :: Pubkey -> Pubkey -> Ordering
$c< :: Pubkey -> Pubkey -> Bool
< :: Pubkey -> Pubkey -> Bool
$c<= :: Pubkey -> Pubkey -> Bool
<= :: Pubkey -> Pubkey -> Bool
$c> :: Pubkey -> Pubkey -> Bool
> :: Pubkey -> Pubkey -> Bool
$c>= :: Pubkey -> Pubkey -> Bool
>= :: Pubkey -> Pubkey -> Bool
$cmax :: Pubkey -> Pubkey -> Pubkey
max :: Pubkey -> Pubkey -> Pubkey
$cmin :: Pubkey -> Pubkey -> Pubkey
min :: Pubkey -> Pubkey -> Pubkey
Ord, Int -> Pubkey -> ShowS
[Pubkey] -> ShowS
Pubkey -> String
(Int -> Pubkey -> ShowS)
-> (Pubkey -> String) -> ([Pubkey] -> ShowS) -> Show Pubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Pubkey -> ShowS
showsPrec :: Int -> Pubkey -> ShowS
$cshow :: Pubkey -> String
show :: Pubkey -> String
$cshowList :: [Pubkey] -> ShowS
showList :: [Pubkey] -> ShowS
Show, (forall x. Pubkey -> Rep Pubkey x)
-> (forall x. Rep Pubkey x -> Pubkey) -> Generic Pubkey
forall x. Rep Pubkey x -> Pubkey
forall x. Pubkey -> Rep Pubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Pubkey -> Rep Pubkey x
from :: forall x. Pubkey -> Rep Pubkey x
$cto :: forall x. Rep Pubkey x -> Pubkey
to :: forall x. Rep Pubkey x -> Pubkey
Generic)

-- | Parse a 33-byte compressed public key.
--
-- Returns Nothing if the input is not exactly 33 bytes.
--
-- >>> pubkey (BS.replicate 33 0x02)
-- Just (Pubkey ...)
-- >>> pubkey (BS.replicate 32 0x02)
-- Nothing
pubkey :: BS.ByteString -> Maybe Pubkey
pubkey :: ByteString -> Maybe Pubkey
pubkey ByteString
bs
  | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
33 = Pubkey -> Maybe Pubkey
forall a. a -> Maybe a
Just (ByteString -> Pubkey
Pubkey ByteString
bs)
  | Bool
otherwise = Maybe Pubkey
forall a. Maybe a
Nothing
{-# INLINE pubkey #-}

-- | Secret key (32 bytes).
newtype Seckey = Seckey { Seckey -> ByteString
unSeckey :: BS.ByteString }
  deriving (Seckey -> Seckey -> Bool
(Seckey -> Seckey -> Bool)
-> (Seckey -> Seckey -> Bool) -> Eq Seckey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Seckey -> Seckey -> Bool
== :: Seckey -> Seckey -> Bool
$c/= :: Seckey -> Seckey -> Bool
/= :: Seckey -> Seckey -> Bool
Eq, (forall x. Seckey -> Rep Seckey x)
-> (forall x. Rep Seckey x -> Seckey) -> Generic Seckey
forall x. Rep Seckey x -> Seckey
forall x. Seckey -> Rep Seckey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Seckey -> Rep Seckey x
from :: forall x. Seckey -> Rep Seckey x
$cto :: forall x. Rep Seckey x -> Seckey
to :: forall x. Rep Seckey x -> Seckey
Generic)

-- Don't show secret keys
instance Show Seckey where
  show :: Seckey -> String
show Seckey
_ = String
"Seckey <redacted>"

-- | Parse a 32-byte secret key.
--
-- Returns Nothing if the input is not exactly 32 bytes.
seckey :: BS.ByteString -> Maybe Seckey
seckey :: ByteString -> Maybe Seckey
seckey ByteString
bs
  | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = Seckey -> Maybe Seckey
forall a. a -> Maybe a
Just (ByteString -> Seckey
Seckey ByteString
bs)
  | Bool
otherwise = Maybe Seckey
forall a. Maybe a
Nothing
{-# INLINE seckey #-}

-- | Elliptic curve point (33-byte compressed form).
newtype Point = Point { Point -> ByteString
unPoint :: BS.ByteString }
  deriving (Point -> Point -> Bool
(Point -> Point -> Bool) -> (Point -> Point -> Bool) -> Eq Point
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Point -> Point -> Bool
== :: Point -> Point -> Bool
$c/= :: Point -> Point -> Bool
/= :: Point -> Point -> Bool
Eq, Eq Point
Eq Point =>
(Point -> Point -> Ordering)
-> (Point -> Point -> Bool)
-> (Point -> Point -> Bool)
-> (Point -> Point -> Bool)
-> (Point -> Point -> Bool)
-> (Point -> Point -> Point)
-> (Point -> Point -> Point)
-> Ord Point
Point -> Point -> Bool
Point -> Point -> Ordering
Point -> Point -> Point
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Point -> Point -> Ordering
compare :: Point -> Point -> Ordering
$c< :: Point -> Point -> Bool
< :: Point -> Point -> Bool
$c<= :: Point -> Point -> Bool
<= :: Point -> Point -> Bool
$c> :: Point -> Point -> Bool
> :: Point -> Point -> Bool
$c>= :: Point -> Point -> Bool
>= :: Point -> Point -> Bool
$cmax :: Point -> Point -> Point
max :: Point -> Point -> Point
$cmin :: Point -> Point -> Point
min :: Point -> Point -> Point
Ord, Int -> Point -> ShowS
[Point] -> ShowS
Point -> String
(Int -> Point -> ShowS)
-> (Point -> String) -> ([Point] -> ShowS) -> Show Point
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Point -> ShowS
showsPrec :: Int -> Point -> ShowS
$cshow :: Point -> String
show :: Point -> String
$cshowList :: [Point] -> ShowS
showList :: [Point] -> ShowS
Show, (forall x. Point -> Rep Point x)
-> (forall x. Rep Point x -> Point) -> Generic Point
forall x. Rep Point x -> Point
forall x. Point -> Rep Point x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Point -> Rep Point x
from :: forall x. Point -> Rep Point x
$cto :: forall x. Rep Point x -> Point
to :: forall x. Rep Point x -> Point
Generic)

-- | Parse a 33-byte elliptic curve point.
--
-- Returns Nothing if the input is not exactly 33 bytes.
point :: BS.ByteString -> Maybe Point
point :: ByteString -> Maybe Point
point ByteString
bs
  | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
33 = Point -> Maybe Point
forall a. a -> Maybe a
Just (ByteString -> Point
Point ByteString
bs)
  | Bool
otherwise = Maybe Point
forall a. Maybe a
Nothing
{-# INLINE point #-}

-- hashes ----------------------------------------------------------------------

-- | Payment hash (32 bytes, SHA256 of preimage).
newtype PaymentHash = PaymentHash { PaymentHash -> ByteString
unPaymentHash :: BS.ByteString }
  deriving (PaymentHash -> PaymentHash -> Bool
(PaymentHash -> PaymentHash -> Bool)
-> (PaymentHash -> PaymentHash -> Bool) -> Eq PaymentHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaymentHash -> PaymentHash -> Bool
== :: PaymentHash -> PaymentHash -> Bool
$c/= :: PaymentHash -> PaymentHash -> Bool
/= :: PaymentHash -> PaymentHash -> Bool
Eq, Eq PaymentHash
Eq PaymentHash =>
(PaymentHash -> PaymentHash -> Ordering)
-> (PaymentHash -> PaymentHash -> Bool)
-> (PaymentHash -> PaymentHash -> Bool)
-> (PaymentHash -> PaymentHash -> Bool)
-> (PaymentHash -> PaymentHash -> Bool)
-> (PaymentHash -> PaymentHash -> PaymentHash)
-> (PaymentHash -> PaymentHash -> PaymentHash)
-> Ord PaymentHash
PaymentHash -> PaymentHash -> Bool
PaymentHash -> PaymentHash -> Ordering
PaymentHash -> PaymentHash -> PaymentHash
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PaymentHash -> PaymentHash -> Ordering
compare :: PaymentHash -> PaymentHash -> Ordering
$c< :: PaymentHash -> PaymentHash -> Bool
< :: PaymentHash -> PaymentHash -> Bool
$c<= :: PaymentHash -> PaymentHash -> Bool
<= :: PaymentHash -> PaymentHash -> Bool
$c> :: PaymentHash -> PaymentHash -> Bool
> :: PaymentHash -> PaymentHash -> Bool
$c>= :: PaymentHash -> PaymentHash -> Bool
>= :: PaymentHash -> PaymentHash -> Bool
$cmax :: PaymentHash -> PaymentHash -> PaymentHash
max :: PaymentHash -> PaymentHash -> PaymentHash
$cmin :: PaymentHash -> PaymentHash -> PaymentHash
min :: PaymentHash -> PaymentHash -> PaymentHash
Ord, Int -> PaymentHash -> ShowS
[PaymentHash] -> ShowS
PaymentHash -> String
(Int -> PaymentHash -> ShowS)
-> (PaymentHash -> String)
-> ([PaymentHash] -> ShowS)
-> Show PaymentHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaymentHash -> ShowS
showsPrec :: Int -> PaymentHash -> ShowS
$cshow :: PaymentHash -> String
show :: PaymentHash -> String
$cshowList :: [PaymentHash] -> ShowS
showList :: [PaymentHash] -> ShowS
Show, (forall x. PaymentHash -> Rep PaymentHash x)
-> (forall x. Rep PaymentHash x -> PaymentHash)
-> Generic PaymentHash
forall x. Rep PaymentHash x -> PaymentHash
forall x. PaymentHash -> Rep PaymentHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PaymentHash -> Rep PaymentHash x
from :: forall x. PaymentHash -> Rep PaymentHash x
$cto :: forall x. Rep PaymentHash x -> PaymentHash
to :: forall x. Rep PaymentHash x -> PaymentHash
Generic)

-- | Parse a 32-byte payment hash.
--
-- Returns Nothing if the input is not exactly 32 bytes.
payment_hash :: BS.ByteString -> Maybe PaymentHash
payment_hash :: ByteString -> Maybe PaymentHash
payment_hash ByteString
bs
  | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = PaymentHash -> Maybe PaymentHash
forall a. a -> Maybe a
Just (ByteString -> PaymentHash
PaymentHash ByteString
bs)
  | Bool
otherwise = Maybe PaymentHash
forall a. Maybe a
Nothing
{-# INLINE payment_hash #-}

-- | Payment preimage (32 bytes).
newtype PaymentPreimage = PaymentPreimage { PaymentPreimage -> ByteString
unPaymentPreimage :: BS.ByteString }
  deriving (PaymentPreimage -> PaymentPreimage -> Bool
(PaymentPreimage -> PaymentPreimage -> Bool)
-> (PaymentPreimage -> PaymentPreimage -> Bool)
-> Eq PaymentPreimage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaymentPreimage -> PaymentPreimage -> Bool
== :: PaymentPreimage -> PaymentPreimage -> Bool
$c/= :: PaymentPreimage -> PaymentPreimage -> Bool
/= :: PaymentPreimage -> PaymentPreimage -> Bool
Eq, (forall x. PaymentPreimage -> Rep PaymentPreimage x)
-> (forall x. Rep PaymentPreimage x -> PaymentPreimage)
-> Generic PaymentPreimage
forall x. Rep PaymentPreimage x -> PaymentPreimage
forall x. PaymentPreimage -> Rep PaymentPreimage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PaymentPreimage -> Rep PaymentPreimage x
from :: forall x. PaymentPreimage -> Rep PaymentPreimage x
$cto :: forall x. Rep PaymentPreimage x -> PaymentPreimage
to :: forall x. Rep PaymentPreimage x -> PaymentPreimage
Generic)

instance Show PaymentPreimage where
  show :: PaymentPreimage -> String
show PaymentPreimage
_ = String
"PaymentPreimage <redacted>"

-- | Parse a 32-byte payment preimage.
--
-- Returns Nothing if the input is not exactly 32 bytes.
payment_preimage :: BS.ByteString -> Maybe PaymentPreimage
payment_preimage :: ByteString -> Maybe PaymentPreimage
payment_preimage ByteString
bs
  | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = PaymentPreimage -> Maybe PaymentPreimage
forall a. a -> Maybe a
Just (ByteString -> PaymentPreimage
PaymentPreimage ByteString
bs)
  | Bool
otherwise = Maybe PaymentPreimage
forall a. Maybe a
Nothing
{-# INLINE payment_preimage #-}

-- transaction primitives ------------------------------------------------------

-- | Transaction ID (32 bytes, little-endian hash).
newtype TxId = TxId { TxId -> ByteString
unTxId :: BS.ByteString }
  deriving (TxId -> TxId -> Bool
(TxId -> TxId -> Bool) -> (TxId -> TxId -> Bool) -> Eq TxId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxId -> TxId -> Bool
== :: TxId -> TxId -> Bool
$c/= :: TxId -> TxId -> Bool
/= :: TxId -> TxId -> Bool
Eq, Eq TxId
Eq TxId =>
(TxId -> TxId -> Ordering)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> TxId)
-> (TxId -> TxId -> TxId)
-> Ord TxId
TxId -> TxId -> Bool
TxId -> TxId -> Ordering
TxId -> TxId -> TxId
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TxId -> TxId -> Ordering
compare :: TxId -> TxId -> Ordering
$c< :: TxId -> TxId -> Bool
< :: TxId -> TxId -> Bool
$c<= :: TxId -> TxId -> Bool
<= :: TxId -> TxId -> Bool
$c> :: TxId -> TxId -> Bool
> :: TxId -> TxId -> Bool
$c>= :: TxId -> TxId -> Bool
>= :: TxId -> TxId -> Bool
$cmax :: TxId -> TxId -> TxId
max :: TxId -> TxId -> TxId
$cmin :: TxId -> TxId -> TxId
min :: TxId -> TxId -> TxId
Ord, Int -> TxId -> ShowS
[TxId] -> ShowS
TxId -> String
(Int -> TxId -> ShowS)
-> (TxId -> String) -> ([TxId] -> ShowS) -> Show TxId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxId -> ShowS
showsPrec :: Int -> TxId -> ShowS
$cshow :: TxId -> String
show :: TxId -> String
$cshowList :: [TxId] -> ShowS
showList :: [TxId] -> ShowS
Show, (forall x. TxId -> Rep TxId x)
-> (forall x. Rep TxId x -> TxId) -> Generic TxId
forall x. Rep TxId x -> TxId
forall x. TxId -> Rep TxId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TxId -> Rep TxId x
from :: forall x. TxId -> Rep TxId x
$cto :: forall x. Rep TxId x -> TxId
to :: forall x. Rep TxId x -> TxId
Generic)

-- | Parse a 32-byte transaction ID.
--
-- Returns Nothing if the input is not exactly 32 bytes.
txid :: BS.ByteString -> Maybe TxId
txid :: ByteString -> Maybe TxId
txid ByteString
bs
  | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = TxId -> Maybe TxId
forall a. a -> Maybe a
Just (ByteString -> TxId
TxId ByteString
bs)
  | Bool
otherwise = Maybe TxId
forall a. Maybe a
Nothing
{-# INLINE txid #-}

-- | Transaction outpoint (txid + output index).
data Outpoint = Outpoint
  { Outpoint -> TxId
outpoint_txid  :: {-# UNPACK #-} !TxId
  , Outpoint -> Word32
outpoint_index :: {-# UNPACK #-} !Word32
  } deriving (Outpoint -> Outpoint -> Bool
(Outpoint -> Outpoint -> Bool)
-> (Outpoint -> Outpoint -> Bool) -> Eq Outpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Outpoint -> Outpoint -> Bool
== :: Outpoint -> Outpoint -> Bool
$c/= :: Outpoint -> Outpoint -> Bool
/= :: Outpoint -> Outpoint -> Bool
Eq, Eq Outpoint
Eq Outpoint =>
(Outpoint -> Outpoint -> Ordering)
-> (Outpoint -> Outpoint -> Bool)
-> (Outpoint -> Outpoint -> Bool)
-> (Outpoint -> Outpoint -> Bool)
-> (Outpoint -> Outpoint -> Bool)
-> (Outpoint -> Outpoint -> Outpoint)
-> (Outpoint -> Outpoint -> Outpoint)
-> Ord Outpoint
Outpoint -> Outpoint -> Bool
Outpoint -> Outpoint -> Ordering
Outpoint -> Outpoint -> Outpoint
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Outpoint -> Outpoint -> Ordering
compare :: Outpoint -> Outpoint -> Ordering
$c< :: Outpoint -> Outpoint -> Bool
< :: Outpoint -> Outpoint -> Bool
$c<= :: Outpoint -> Outpoint -> Bool
<= :: Outpoint -> Outpoint -> Bool
$c> :: Outpoint -> Outpoint -> Bool
> :: Outpoint -> Outpoint -> Bool
$c>= :: Outpoint -> Outpoint -> Bool
>= :: Outpoint -> Outpoint -> Bool
$cmax :: Outpoint -> Outpoint -> Outpoint
max :: Outpoint -> Outpoint -> Outpoint
$cmin :: Outpoint -> Outpoint -> Outpoint
min :: Outpoint -> Outpoint -> Outpoint
Ord, Int -> Outpoint -> ShowS
[Outpoint] -> ShowS
Outpoint -> String
(Int -> Outpoint -> ShowS)
-> (Outpoint -> String) -> ([Outpoint] -> ShowS) -> Show Outpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Outpoint -> ShowS
showsPrec :: Int -> Outpoint -> ShowS
$cshow :: Outpoint -> String
show :: Outpoint -> String
$cshowList :: [Outpoint] -> ShowS
showList :: [Outpoint] -> ShowS
Show, (forall x. Outpoint -> Rep Outpoint x)
-> (forall x. Rep Outpoint x -> Outpoint) -> Generic Outpoint
forall x. Rep Outpoint x -> Outpoint
forall x. Outpoint -> Rep Outpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Outpoint -> Rep Outpoint x
from :: forall x. Outpoint -> Rep Outpoint x
$cto :: forall x. Rep Outpoint x -> Outpoint
to :: forall x. Rep Outpoint x -> Outpoint
Generic)

-- | Transaction input sequence number.
newtype Sequence = Sequence { Sequence -> Word32
unSequence :: Word32 }
  deriving (Sequence -> Sequence -> Bool
(Sequence -> Sequence -> Bool)
-> (Sequence -> Sequence -> Bool) -> Eq Sequence
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Sequence -> Sequence -> Bool
== :: Sequence -> Sequence -> Bool
$c/= :: Sequence -> Sequence -> Bool
/= :: Sequence -> Sequence -> Bool
Eq, Eq Sequence
Eq Sequence =>
(Sequence -> Sequence -> Ordering)
-> (Sequence -> Sequence -> Bool)
-> (Sequence -> Sequence -> Bool)
-> (Sequence -> Sequence -> Bool)
-> (Sequence -> Sequence -> Bool)
-> (Sequence -> Sequence -> Sequence)
-> (Sequence -> Sequence -> Sequence)
-> Ord Sequence
Sequence -> Sequence -> Bool
Sequence -> Sequence -> Ordering
Sequence -> Sequence -> Sequence
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Sequence -> Sequence -> Ordering
compare :: Sequence -> Sequence -> Ordering
$c< :: Sequence -> Sequence -> Bool
< :: Sequence -> Sequence -> Bool
$c<= :: Sequence -> Sequence -> Bool
<= :: Sequence -> Sequence -> Bool
$c> :: Sequence -> Sequence -> Bool
> :: Sequence -> Sequence -> Bool
$c>= :: Sequence -> Sequence -> Bool
>= :: Sequence -> Sequence -> Bool
$cmax :: Sequence -> Sequence -> Sequence
max :: Sequence -> Sequence -> Sequence
$cmin :: Sequence -> Sequence -> Sequence
min :: Sequence -> Sequence -> Sequence
Ord, Int -> Sequence -> ShowS
[Sequence] -> ShowS
Sequence -> String
(Int -> Sequence -> ShowS)
-> (Sequence -> String) -> ([Sequence] -> ShowS) -> Show Sequence
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Sequence -> ShowS
showsPrec :: Int -> Sequence -> ShowS
$cshow :: Sequence -> String
show :: Sequence -> String
$cshowList :: [Sequence] -> ShowS
showList :: [Sequence] -> ShowS
Show, (forall x. Sequence -> Rep Sequence x)
-> (forall x. Rep Sequence x -> Sequence) -> Generic Sequence
forall x. Rep Sequence x -> Sequence
forall x. Sequence -> Rep Sequence x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Sequence -> Rep Sequence x
from :: forall x. Sequence -> Rep Sequence x
$cto :: forall x. Rep Sequence x -> Sequence
to :: forall x. Rep Sequence x -> Sequence
Generic, Integer -> Sequence
Sequence -> Sequence
Sequence -> Sequence -> Sequence
(Sequence -> Sequence -> Sequence)
-> (Sequence -> Sequence -> Sequence)
-> (Sequence -> Sequence -> Sequence)
-> (Sequence -> Sequence)
-> (Sequence -> Sequence)
-> (Sequence -> Sequence)
-> (Integer -> Sequence)
-> Num Sequence
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: Sequence -> Sequence -> Sequence
+ :: Sequence -> Sequence -> Sequence
$c- :: Sequence -> Sequence -> Sequence
- :: Sequence -> Sequence -> Sequence
$c* :: Sequence -> Sequence -> Sequence
* :: Sequence -> Sequence -> Sequence
$cnegate :: Sequence -> Sequence
negate :: Sequence -> Sequence
$cabs :: Sequence -> Sequence
abs :: Sequence -> Sequence
$csignum :: Sequence -> Sequence
signum :: Sequence -> Sequence
$cfromInteger :: Integer -> Sequence
fromInteger :: Integer -> Sequence
Num)

-- | Transaction locktime.
newtype Locktime = Locktime { Locktime -> Word32
unLocktime :: Word32 }
  deriving (Locktime -> Locktime -> Bool
(Locktime -> Locktime -> Bool)
-> (Locktime -> Locktime -> Bool) -> Eq Locktime
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Locktime -> Locktime -> Bool
== :: Locktime -> Locktime -> Bool
$c/= :: Locktime -> Locktime -> Bool
/= :: Locktime -> Locktime -> Bool
Eq, Eq Locktime
Eq Locktime =>
(Locktime -> Locktime -> Ordering)
-> (Locktime -> Locktime -> Bool)
-> (Locktime -> Locktime -> Bool)
-> (Locktime -> Locktime -> Bool)
-> (Locktime -> Locktime -> Bool)
-> (Locktime -> Locktime -> Locktime)
-> (Locktime -> Locktime -> Locktime)
-> Ord Locktime
Locktime -> Locktime -> Bool
Locktime -> Locktime -> Ordering
Locktime -> Locktime -> Locktime
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Locktime -> Locktime -> Ordering
compare :: Locktime -> Locktime -> Ordering
$c< :: Locktime -> Locktime -> Bool
< :: Locktime -> Locktime -> Bool
$c<= :: Locktime -> Locktime -> Bool
<= :: Locktime -> Locktime -> Bool
$c> :: Locktime -> Locktime -> Bool
> :: Locktime -> Locktime -> Bool
$c>= :: Locktime -> Locktime -> Bool
>= :: Locktime -> Locktime -> Bool
$cmax :: Locktime -> Locktime -> Locktime
max :: Locktime -> Locktime -> Locktime
$cmin :: Locktime -> Locktime -> Locktime
min :: Locktime -> Locktime -> Locktime
Ord, Int -> Locktime -> ShowS
[Locktime] -> ShowS
Locktime -> String
(Int -> Locktime -> ShowS)
-> (Locktime -> String) -> ([Locktime] -> ShowS) -> Show Locktime
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Locktime -> ShowS
showsPrec :: Int -> Locktime -> ShowS
$cshow :: Locktime -> String
show :: Locktime -> String
$cshowList :: [Locktime] -> ShowS
showList :: [Locktime] -> ShowS
Show, (forall x. Locktime -> Rep Locktime x)
-> (forall x. Rep Locktime x -> Locktime) -> Generic Locktime
forall x. Rep Locktime x -> Locktime
forall x. Locktime -> Rep Locktime x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Locktime -> Rep Locktime x
from :: forall x. Locktime -> Rep Locktime x
$cto :: forall x. Rep Locktime x -> Locktime
to :: forall x. Rep Locktime x -> Locktime
Generic, Integer -> Locktime
Locktime -> Locktime
Locktime -> Locktime -> Locktime
(Locktime -> Locktime -> Locktime)
-> (Locktime -> Locktime -> Locktime)
-> (Locktime -> Locktime -> Locktime)
-> (Locktime -> Locktime)
-> (Locktime -> Locktime)
-> (Locktime -> Locktime)
-> (Integer -> Locktime)
-> Num Locktime
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: Locktime -> Locktime -> Locktime
+ :: Locktime -> Locktime -> Locktime
$c- :: Locktime -> Locktime -> Locktime
- :: Locktime -> Locktime -> Locktime
$c* :: Locktime -> Locktime -> Locktime
* :: Locktime -> Locktime -> Locktime
$cnegate :: Locktime -> Locktime
negate :: Locktime -> Locktime
$cabs :: Locktime -> Locktime
abs :: Locktime -> Locktime
$csignum :: Locktime -> Locktime
signum :: Locktime -> Locktime
$cfromInteger :: Integer -> Locktime
fromInteger :: Integer -> Locktime
Num)

-- channel parameters ----------------------------------------------------------

-- | 48-bit commitment number.
newtype CommitmentNumber = CommitmentNumber { CommitmentNumber -> Word64
unCommitmentNumber :: Word64 }
  deriving (CommitmentNumber -> CommitmentNumber -> Bool
(CommitmentNumber -> CommitmentNumber -> Bool)
-> (CommitmentNumber -> CommitmentNumber -> Bool)
-> Eq CommitmentNumber
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommitmentNumber -> CommitmentNumber -> Bool
== :: CommitmentNumber -> CommitmentNumber -> Bool
$c/= :: CommitmentNumber -> CommitmentNumber -> Bool
/= :: CommitmentNumber -> CommitmentNumber -> Bool
Eq, Eq CommitmentNumber
Eq CommitmentNumber =>
(CommitmentNumber -> CommitmentNumber -> Ordering)
-> (CommitmentNumber -> CommitmentNumber -> Bool)
-> (CommitmentNumber -> CommitmentNumber -> Bool)
-> (CommitmentNumber -> CommitmentNumber -> Bool)
-> (CommitmentNumber -> CommitmentNumber -> Bool)
-> (CommitmentNumber -> CommitmentNumber -> CommitmentNumber)
-> (CommitmentNumber -> CommitmentNumber -> CommitmentNumber)
-> Ord CommitmentNumber
CommitmentNumber -> CommitmentNumber -> Bool
CommitmentNumber -> CommitmentNumber -> Ordering
CommitmentNumber -> CommitmentNumber -> CommitmentNumber
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CommitmentNumber -> CommitmentNumber -> Ordering
compare :: CommitmentNumber -> CommitmentNumber -> Ordering
$c< :: CommitmentNumber -> CommitmentNumber -> Bool
< :: CommitmentNumber -> CommitmentNumber -> Bool
$c<= :: CommitmentNumber -> CommitmentNumber -> Bool
<= :: CommitmentNumber -> CommitmentNumber -> Bool
$c> :: CommitmentNumber -> CommitmentNumber -> Bool
> :: CommitmentNumber -> CommitmentNumber -> Bool
$c>= :: CommitmentNumber -> CommitmentNumber -> Bool
>= :: CommitmentNumber -> CommitmentNumber -> Bool
$cmax :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
max :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
$cmin :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
min :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
Ord, Int -> CommitmentNumber -> ShowS
[CommitmentNumber] -> ShowS
CommitmentNumber -> String
(Int -> CommitmentNumber -> ShowS)
-> (CommitmentNumber -> String)
-> ([CommitmentNumber] -> ShowS)
-> Show CommitmentNumber
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommitmentNumber -> ShowS
showsPrec :: Int -> CommitmentNumber -> ShowS
$cshow :: CommitmentNumber -> String
show :: CommitmentNumber -> String
$cshowList :: [CommitmentNumber] -> ShowS
showList :: [CommitmentNumber] -> ShowS
Show, (forall x. CommitmentNumber -> Rep CommitmentNumber x)
-> (forall x. Rep CommitmentNumber x -> CommitmentNumber)
-> Generic CommitmentNumber
forall x. Rep CommitmentNumber x -> CommitmentNumber
forall x. CommitmentNumber -> Rep CommitmentNumber x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CommitmentNumber -> Rep CommitmentNumber x
from :: forall x. CommitmentNumber -> Rep CommitmentNumber x
$cto :: forall x. Rep CommitmentNumber x -> CommitmentNumber
to :: forall x. Rep CommitmentNumber x -> CommitmentNumber
Generic, Integer -> CommitmentNumber
CommitmentNumber -> CommitmentNumber
CommitmentNumber -> CommitmentNumber -> CommitmentNumber
(CommitmentNumber -> CommitmentNumber -> CommitmentNumber)
-> (CommitmentNumber -> CommitmentNumber -> CommitmentNumber)
-> (CommitmentNumber -> CommitmentNumber -> CommitmentNumber)
-> (CommitmentNumber -> CommitmentNumber)
-> (CommitmentNumber -> CommitmentNumber)
-> (CommitmentNumber -> CommitmentNumber)
-> (Integer -> CommitmentNumber)
-> Num CommitmentNumber
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
+ :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
$c- :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
- :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
$c* :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
* :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber
$cnegate :: CommitmentNumber -> CommitmentNumber
negate :: CommitmentNumber -> CommitmentNumber
$cabs :: CommitmentNumber -> CommitmentNumber
abs :: CommitmentNumber -> CommitmentNumber
$csignum :: CommitmentNumber -> CommitmentNumber
signum :: CommitmentNumber -> CommitmentNumber
$cfromInteger :: Integer -> CommitmentNumber
fromInteger :: Integer -> CommitmentNumber
Num)

-- | Parse a 48-bit commitment number.
--
-- Returns Nothing if the value exceeds 2^48 - 1.
commitment_number :: Word64 -> Maybe CommitmentNumber
commitment_number :: Word64 -> Maybe CommitmentNumber
commitment_number Word64
n
  | Word64
n Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
<= Word64
281474976710655 = CommitmentNumber -> Maybe CommitmentNumber
forall a. a -> Maybe a
Just (Word64 -> CommitmentNumber
CommitmentNumber Word64
n)
  | Bool
otherwise = Maybe CommitmentNumber
forall a. Maybe a
Nothing
{-# INLINE commitment_number #-}

-- | CSV delay for to_local outputs.
newtype ToSelfDelay = ToSelfDelay { ToSelfDelay -> Word16
unToSelfDelay :: Word16 }
  deriving (ToSelfDelay -> ToSelfDelay -> Bool
(ToSelfDelay -> ToSelfDelay -> Bool)
-> (ToSelfDelay -> ToSelfDelay -> Bool) -> Eq ToSelfDelay
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToSelfDelay -> ToSelfDelay -> Bool
== :: ToSelfDelay -> ToSelfDelay -> Bool
$c/= :: ToSelfDelay -> ToSelfDelay -> Bool
/= :: ToSelfDelay -> ToSelfDelay -> Bool
Eq, Eq ToSelfDelay
Eq ToSelfDelay =>
(ToSelfDelay -> ToSelfDelay -> Ordering)
-> (ToSelfDelay -> ToSelfDelay -> Bool)
-> (ToSelfDelay -> ToSelfDelay -> Bool)
-> (ToSelfDelay -> ToSelfDelay -> Bool)
-> (ToSelfDelay -> ToSelfDelay -> Bool)
-> (ToSelfDelay -> ToSelfDelay -> ToSelfDelay)
-> (ToSelfDelay -> ToSelfDelay -> ToSelfDelay)
-> Ord ToSelfDelay
ToSelfDelay -> ToSelfDelay -> Bool
ToSelfDelay -> ToSelfDelay -> Ordering
ToSelfDelay -> ToSelfDelay -> ToSelfDelay
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ToSelfDelay -> ToSelfDelay -> Ordering
compare :: ToSelfDelay -> ToSelfDelay -> Ordering
$c< :: ToSelfDelay -> ToSelfDelay -> Bool
< :: ToSelfDelay -> ToSelfDelay -> Bool
$c<= :: ToSelfDelay -> ToSelfDelay -> Bool
<= :: ToSelfDelay -> ToSelfDelay -> Bool
$c> :: ToSelfDelay -> ToSelfDelay -> Bool
> :: ToSelfDelay -> ToSelfDelay -> Bool
$c>= :: ToSelfDelay -> ToSelfDelay -> Bool
>= :: ToSelfDelay -> ToSelfDelay -> Bool
$cmax :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
max :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
$cmin :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
min :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
Ord, Int -> ToSelfDelay -> ShowS
[ToSelfDelay] -> ShowS
ToSelfDelay -> String
(Int -> ToSelfDelay -> ShowS)
-> (ToSelfDelay -> String)
-> ([ToSelfDelay] -> ShowS)
-> Show ToSelfDelay
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToSelfDelay -> ShowS
showsPrec :: Int -> ToSelfDelay -> ShowS
$cshow :: ToSelfDelay -> String
show :: ToSelfDelay -> String
$cshowList :: [ToSelfDelay] -> ShowS
showList :: [ToSelfDelay] -> ShowS
Show, (forall x. ToSelfDelay -> Rep ToSelfDelay x)
-> (forall x. Rep ToSelfDelay x -> ToSelfDelay)
-> Generic ToSelfDelay
forall x. Rep ToSelfDelay x -> ToSelfDelay
forall x. ToSelfDelay -> Rep ToSelfDelay x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ToSelfDelay -> Rep ToSelfDelay x
from :: forall x. ToSelfDelay -> Rep ToSelfDelay x
$cto :: forall x. Rep ToSelfDelay x -> ToSelfDelay
to :: forall x. Rep ToSelfDelay x -> ToSelfDelay
Generic, Integer -> ToSelfDelay
ToSelfDelay -> ToSelfDelay
ToSelfDelay -> ToSelfDelay -> ToSelfDelay
(ToSelfDelay -> ToSelfDelay -> ToSelfDelay)
-> (ToSelfDelay -> ToSelfDelay -> ToSelfDelay)
-> (ToSelfDelay -> ToSelfDelay -> ToSelfDelay)
-> (ToSelfDelay -> ToSelfDelay)
-> (ToSelfDelay -> ToSelfDelay)
-> (ToSelfDelay -> ToSelfDelay)
-> (Integer -> ToSelfDelay)
-> Num ToSelfDelay
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
+ :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
$c- :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
- :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
$c* :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
* :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay
$cnegate :: ToSelfDelay -> ToSelfDelay
negate :: ToSelfDelay -> ToSelfDelay
$cabs :: ToSelfDelay -> ToSelfDelay
abs :: ToSelfDelay -> ToSelfDelay
$csignum :: ToSelfDelay -> ToSelfDelay
signum :: ToSelfDelay -> ToSelfDelay
$cfromInteger :: Integer -> ToSelfDelay
fromInteger :: Integer -> ToSelfDelay
Num)

-- | CLTV expiry for HTLCs.
newtype CltvExpiry = CltvExpiry { CltvExpiry -> Word32
unCltvExpiry :: Word32 }
  deriving (CltvExpiry -> CltvExpiry -> Bool
(CltvExpiry -> CltvExpiry -> Bool)
-> (CltvExpiry -> CltvExpiry -> Bool) -> Eq CltvExpiry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CltvExpiry -> CltvExpiry -> Bool
== :: CltvExpiry -> CltvExpiry -> Bool
$c/= :: CltvExpiry -> CltvExpiry -> Bool
/= :: CltvExpiry -> CltvExpiry -> Bool
Eq, Eq CltvExpiry
Eq CltvExpiry =>
(CltvExpiry -> CltvExpiry -> Ordering)
-> (CltvExpiry -> CltvExpiry -> Bool)
-> (CltvExpiry -> CltvExpiry -> Bool)
-> (CltvExpiry -> CltvExpiry -> Bool)
-> (CltvExpiry -> CltvExpiry -> Bool)
-> (CltvExpiry -> CltvExpiry -> CltvExpiry)
-> (CltvExpiry -> CltvExpiry -> CltvExpiry)
-> Ord CltvExpiry
CltvExpiry -> CltvExpiry -> Bool
CltvExpiry -> CltvExpiry -> Ordering
CltvExpiry -> CltvExpiry -> CltvExpiry
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CltvExpiry -> CltvExpiry -> Ordering
compare :: CltvExpiry -> CltvExpiry -> Ordering
$c< :: CltvExpiry -> CltvExpiry -> Bool
< :: CltvExpiry -> CltvExpiry -> Bool
$c<= :: CltvExpiry -> CltvExpiry -> Bool
<= :: CltvExpiry -> CltvExpiry -> Bool
$c> :: CltvExpiry -> CltvExpiry -> Bool
> :: CltvExpiry -> CltvExpiry -> Bool
$c>= :: CltvExpiry -> CltvExpiry -> Bool
>= :: CltvExpiry -> CltvExpiry -> Bool
$cmax :: CltvExpiry -> CltvExpiry -> CltvExpiry
max :: CltvExpiry -> CltvExpiry -> CltvExpiry
$cmin :: CltvExpiry -> CltvExpiry -> CltvExpiry
min :: CltvExpiry -> CltvExpiry -> CltvExpiry
Ord, Int -> CltvExpiry -> ShowS
[CltvExpiry] -> ShowS
CltvExpiry -> String
(Int -> CltvExpiry -> ShowS)
-> (CltvExpiry -> String)
-> ([CltvExpiry] -> ShowS)
-> Show CltvExpiry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CltvExpiry -> ShowS
showsPrec :: Int -> CltvExpiry -> ShowS
$cshow :: CltvExpiry -> String
show :: CltvExpiry -> String
$cshowList :: [CltvExpiry] -> ShowS
showList :: [CltvExpiry] -> ShowS
Show, (forall x. CltvExpiry -> Rep CltvExpiry x)
-> (forall x. Rep CltvExpiry x -> CltvExpiry) -> Generic CltvExpiry
forall x. Rep CltvExpiry x -> CltvExpiry
forall x. CltvExpiry -> Rep CltvExpiry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CltvExpiry -> Rep CltvExpiry x
from :: forall x. CltvExpiry -> Rep CltvExpiry x
$cto :: forall x. Rep CltvExpiry x -> CltvExpiry
to :: forall x. Rep CltvExpiry x -> CltvExpiry
Generic, Integer -> CltvExpiry
CltvExpiry -> CltvExpiry
CltvExpiry -> CltvExpiry -> CltvExpiry
(CltvExpiry -> CltvExpiry -> CltvExpiry)
-> (CltvExpiry -> CltvExpiry -> CltvExpiry)
-> (CltvExpiry -> CltvExpiry -> CltvExpiry)
-> (CltvExpiry -> CltvExpiry)
-> (CltvExpiry -> CltvExpiry)
-> (CltvExpiry -> CltvExpiry)
-> (Integer -> CltvExpiry)
-> Num CltvExpiry
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: CltvExpiry -> CltvExpiry -> CltvExpiry
+ :: CltvExpiry -> CltvExpiry -> CltvExpiry
$c- :: CltvExpiry -> CltvExpiry -> CltvExpiry
- :: CltvExpiry -> CltvExpiry -> CltvExpiry
$c* :: CltvExpiry -> CltvExpiry -> CltvExpiry
* :: CltvExpiry -> CltvExpiry -> CltvExpiry
$cnegate :: CltvExpiry -> CltvExpiry
negate :: CltvExpiry -> CltvExpiry
$cabs :: CltvExpiry -> CltvExpiry
abs :: CltvExpiry -> CltvExpiry
$csignum :: CltvExpiry -> CltvExpiry
signum :: CltvExpiry -> CltvExpiry
$cfromInteger :: Integer -> CltvExpiry
fromInteger :: Integer -> CltvExpiry
Num)

-- | Dust limit threshold.
newtype DustLimit = DustLimit { DustLimit -> Satoshi
unDustLimit :: Satoshi }
  deriving (DustLimit -> DustLimit -> Bool
(DustLimit -> DustLimit -> Bool)
-> (DustLimit -> DustLimit -> Bool) -> Eq DustLimit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DustLimit -> DustLimit -> Bool
== :: DustLimit -> DustLimit -> Bool
$c/= :: DustLimit -> DustLimit -> Bool
/= :: DustLimit -> DustLimit -> Bool
Eq, Eq DustLimit
Eq DustLimit =>
(DustLimit -> DustLimit -> Ordering)
-> (DustLimit -> DustLimit -> Bool)
-> (DustLimit -> DustLimit -> Bool)
-> (DustLimit -> DustLimit -> Bool)
-> (DustLimit -> DustLimit -> Bool)
-> (DustLimit -> DustLimit -> DustLimit)
-> (DustLimit -> DustLimit -> DustLimit)
-> Ord DustLimit
DustLimit -> DustLimit -> Bool
DustLimit -> DustLimit -> Ordering
DustLimit -> DustLimit -> DustLimit
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DustLimit -> DustLimit -> Ordering
compare :: DustLimit -> DustLimit -> Ordering
$c< :: DustLimit -> DustLimit -> Bool
< :: DustLimit -> DustLimit -> Bool
$c<= :: DustLimit -> DustLimit -> Bool
<= :: DustLimit -> DustLimit -> Bool
$c> :: DustLimit -> DustLimit -> Bool
> :: DustLimit -> DustLimit -> Bool
$c>= :: DustLimit -> DustLimit -> Bool
>= :: DustLimit -> DustLimit -> Bool
$cmax :: DustLimit -> DustLimit -> DustLimit
max :: DustLimit -> DustLimit -> DustLimit
$cmin :: DustLimit -> DustLimit -> DustLimit
min :: DustLimit -> DustLimit -> DustLimit
Ord, Int -> DustLimit -> ShowS
[DustLimit] -> ShowS
DustLimit -> String
(Int -> DustLimit -> ShowS)
-> (DustLimit -> String)
-> ([DustLimit] -> ShowS)
-> Show DustLimit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DustLimit -> ShowS
showsPrec :: Int -> DustLimit -> ShowS
$cshow :: DustLimit -> String
show :: DustLimit -> String
$cshowList :: [DustLimit] -> ShowS
showList :: [DustLimit] -> ShowS
Show, (forall x. DustLimit -> Rep DustLimit x)
-> (forall x. Rep DustLimit x -> DustLimit) -> Generic DustLimit
forall x. Rep DustLimit x -> DustLimit
forall x. DustLimit -> Rep DustLimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DustLimit -> Rep DustLimit x
from :: forall x. DustLimit -> Rep DustLimit x
$cto :: forall x. Rep DustLimit x -> DustLimit
to :: forall x. Rep DustLimit x -> DustLimit
Generic)

-- | Fee rate in satoshis per 1000 weight units.
newtype FeeratePerKw = FeeratePerKw { FeeratePerKw -> Word32
unFeeratePerKw :: Word32 }
  deriving (FeeratePerKw -> FeeratePerKw -> Bool
(FeeratePerKw -> FeeratePerKw -> Bool)
-> (FeeratePerKw -> FeeratePerKw -> Bool) -> Eq FeeratePerKw
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FeeratePerKw -> FeeratePerKw -> Bool
== :: FeeratePerKw -> FeeratePerKw -> Bool
$c/= :: FeeratePerKw -> FeeratePerKw -> Bool
/= :: FeeratePerKw -> FeeratePerKw -> Bool
Eq, Eq FeeratePerKw
Eq FeeratePerKw =>
(FeeratePerKw -> FeeratePerKw -> Ordering)
-> (FeeratePerKw -> FeeratePerKw -> Bool)
-> (FeeratePerKw -> FeeratePerKw -> Bool)
-> (FeeratePerKw -> FeeratePerKw -> Bool)
-> (FeeratePerKw -> FeeratePerKw -> Bool)
-> (FeeratePerKw -> FeeratePerKw -> FeeratePerKw)
-> (FeeratePerKw -> FeeratePerKw -> FeeratePerKw)
-> Ord FeeratePerKw
FeeratePerKw -> FeeratePerKw -> Bool
FeeratePerKw -> FeeratePerKw -> Ordering
FeeratePerKw -> FeeratePerKw -> FeeratePerKw
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FeeratePerKw -> FeeratePerKw -> Ordering
compare :: FeeratePerKw -> FeeratePerKw -> Ordering
$c< :: FeeratePerKw -> FeeratePerKw -> Bool
< :: FeeratePerKw -> FeeratePerKw -> Bool
$c<= :: FeeratePerKw -> FeeratePerKw -> Bool
<= :: FeeratePerKw -> FeeratePerKw -> Bool
$c> :: FeeratePerKw -> FeeratePerKw -> Bool
> :: FeeratePerKw -> FeeratePerKw -> Bool
$c>= :: FeeratePerKw -> FeeratePerKw -> Bool
>= :: FeeratePerKw -> FeeratePerKw -> Bool
$cmax :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
max :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
$cmin :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
min :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
Ord, Int -> FeeratePerKw -> ShowS
[FeeratePerKw] -> ShowS
FeeratePerKw -> String
(Int -> FeeratePerKw -> ShowS)
-> (FeeratePerKw -> String)
-> ([FeeratePerKw] -> ShowS)
-> Show FeeratePerKw
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FeeratePerKw -> ShowS
showsPrec :: Int -> FeeratePerKw -> ShowS
$cshow :: FeeratePerKw -> String
show :: FeeratePerKw -> String
$cshowList :: [FeeratePerKw] -> ShowS
showList :: [FeeratePerKw] -> ShowS
Show, (forall x. FeeratePerKw -> Rep FeeratePerKw x)
-> (forall x. Rep FeeratePerKw x -> FeeratePerKw)
-> Generic FeeratePerKw
forall x. Rep FeeratePerKw x -> FeeratePerKw
forall x. FeeratePerKw -> Rep FeeratePerKw x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FeeratePerKw -> Rep FeeratePerKw x
from :: forall x. FeeratePerKw -> Rep FeeratePerKw x
$cto :: forall x. Rep FeeratePerKw x -> FeeratePerKw
to :: forall x. Rep FeeratePerKw x -> FeeratePerKw
Generic, Integer -> FeeratePerKw
FeeratePerKw -> FeeratePerKw
FeeratePerKw -> FeeratePerKw -> FeeratePerKw
(FeeratePerKw -> FeeratePerKw -> FeeratePerKw)
-> (FeeratePerKw -> FeeratePerKw -> FeeratePerKw)
-> (FeeratePerKw -> FeeratePerKw -> FeeratePerKw)
-> (FeeratePerKw -> FeeratePerKw)
-> (FeeratePerKw -> FeeratePerKw)
-> (FeeratePerKw -> FeeratePerKw)
-> (Integer -> FeeratePerKw)
-> Num FeeratePerKw
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
+ :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
$c- :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
- :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
$c* :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
* :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw
$cnegate :: FeeratePerKw -> FeeratePerKw
negate :: FeeratePerKw -> FeeratePerKw
$cabs :: FeeratePerKw -> FeeratePerKw
abs :: FeeratePerKw -> FeeratePerKw
$csignum :: FeeratePerKw -> FeeratePerKw
signum :: FeeratePerKw -> FeeratePerKw
$cfromInteger :: Integer -> FeeratePerKw
fromInteger :: Integer -> FeeratePerKw
Num)

-- HTLC types ------------------------------------------------------------------

-- | Direction of an HTLC from the commitment tx owner's perspective.
data HTLCDirection
  = HTLCOffered   -- ^ We offered this HTLC (outgoing)
  | HTLCReceived  -- ^ We received this HTLC (incoming)
  deriving (HTLCDirection -> HTLCDirection -> Bool
(HTLCDirection -> HTLCDirection -> Bool)
-> (HTLCDirection -> HTLCDirection -> Bool) -> Eq HTLCDirection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HTLCDirection -> HTLCDirection -> Bool
== :: HTLCDirection -> HTLCDirection -> Bool
$c/= :: HTLCDirection -> HTLCDirection -> Bool
/= :: HTLCDirection -> HTLCDirection -> Bool
Eq, Eq HTLCDirection
Eq HTLCDirection =>
(HTLCDirection -> HTLCDirection -> Ordering)
-> (HTLCDirection -> HTLCDirection -> Bool)
-> (HTLCDirection -> HTLCDirection -> Bool)
-> (HTLCDirection -> HTLCDirection -> Bool)
-> (HTLCDirection -> HTLCDirection -> Bool)
-> (HTLCDirection -> HTLCDirection -> HTLCDirection)
-> (HTLCDirection -> HTLCDirection -> HTLCDirection)
-> Ord HTLCDirection
HTLCDirection -> HTLCDirection -> Bool
HTLCDirection -> HTLCDirection -> Ordering
HTLCDirection -> HTLCDirection -> HTLCDirection
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: HTLCDirection -> HTLCDirection -> Ordering
compare :: HTLCDirection -> HTLCDirection -> Ordering
$c< :: HTLCDirection -> HTLCDirection -> Bool
< :: HTLCDirection -> HTLCDirection -> Bool
$c<= :: HTLCDirection -> HTLCDirection -> Bool
<= :: HTLCDirection -> HTLCDirection -> Bool
$c> :: HTLCDirection -> HTLCDirection -> Bool
> :: HTLCDirection -> HTLCDirection -> Bool
$c>= :: HTLCDirection -> HTLCDirection -> Bool
>= :: HTLCDirection -> HTLCDirection -> Bool
$cmax :: HTLCDirection -> HTLCDirection -> HTLCDirection
max :: HTLCDirection -> HTLCDirection -> HTLCDirection
$cmin :: HTLCDirection -> HTLCDirection -> HTLCDirection
min :: HTLCDirection -> HTLCDirection -> HTLCDirection
Ord, Int -> HTLCDirection -> ShowS
[HTLCDirection] -> ShowS
HTLCDirection -> String
(Int -> HTLCDirection -> ShowS)
-> (HTLCDirection -> String)
-> ([HTLCDirection] -> ShowS)
-> Show HTLCDirection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HTLCDirection -> ShowS
showsPrec :: Int -> HTLCDirection -> ShowS
$cshow :: HTLCDirection -> String
show :: HTLCDirection -> String
$cshowList :: [HTLCDirection] -> ShowS
showList :: [HTLCDirection] -> ShowS
Show, (forall x. HTLCDirection -> Rep HTLCDirection x)
-> (forall x. Rep HTLCDirection x -> HTLCDirection)
-> Generic HTLCDirection
forall x. Rep HTLCDirection x -> HTLCDirection
forall x. HTLCDirection -> Rep HTLCDirection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HTLCDirection -> Rep HTLCDirection x
from :: forall x. HTLCDirection -> Rep HTLCDirection x
$cto :: forall x. Rep HTLCDirection x -> HTLCDirection
to :: forall x. Rep HTLCDirection x -> HTLCDirection
Generic)

-- | HTLC output details.
--
-- NOTE: No Ord instance is provided. BOLT #3 requires output ordering by
-- amount then scriptPubKey, but scriptPubKey depends on derived keys which
-- are not available here. Use 'sort_outputs' in Tx module for proper BIP69
-- output ordering.
data HTLC = HTLC
  { HTLC -> HTLCDirection
htlc_direction    :: !HTLCDirection
  , HTLC -> MilliSatoshi
htlc_amount_msat  :: {-# UNPACK #-} !MilliSatoshi
  , HTLC -> PaymentHash
htlc_payment_hash :: {-# UNPACK #-} !PaymentHash
  , HTLC -> CltvExpiry
htlc_cltv_expiry  :: {-# UNPACK #-} !CltvExpiry
  } deriving (HTLC -> HTLC -> Bool
(HTLC -> HTLC -> Bool) -> (HTLC -> HTLC -> Bool) -> Eq HTLC
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HTLC -> HTLC -> Bool
== :: HTLC -> HTLC -> Bool
$c/= :: HTLC -> HTLC -> Bool
/= :: HTLC -> HTLC -> Bool
Eq, Int -> HTLC -> ShowS
[HTLC] -> ShowS
HTLC -> String
(Int -> HTLC -> ShowS)
-> (HTLC -> String) -> ([HTLC] -> ShowS) -> Show HTLC
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HTLC -> ShowS
showsPrec :: Int -> HTLC -> ShowS
$cshow :: HTLC -> String
show :: HTLC -> String
$cshowList :: [HTLC] -> ShowS
showList :: [HTLC] -> ShowS
Show, (forall x. HTLC -> Rep HTLC x)
-> (forall x. Rep HTLC x -> HTLC) -> Generic HTLC
forall x. Rep HTLC x -> HTLC
forall x. HTLC -> Rep HTLC x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HTLC -> Rep HTLC x
from :: forall x. HTLC -> Rep HTLC x
$cto :: forall x. Rep HTLC x -> HTLC
to :: forall x. Rep HTLC x -> HTLC
Generic)

-- basepoints ------------------------------------------------------------------

-- | Per-commitment point (used to derive keys).
newtype PerCommitmentPoint = PerCommitmentPoint { PerCommitmentPoint -> Point
unPerCommitmentPoint :: Point }
  deriving (PerCommitmentPoint -> PerCommitmentPoint -> Bool
(PerCommitmentPoint -> PerCommitmentPoint -> Bool)
-> (PerCommitmentPoint -> PerCommitmentPoint -> Bool)
-> Eq PerCommitmentPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
== :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
$c/= :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
/= :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
Eq, Eq PerCommitmentPoint
Eq PerCommitmentPoint =>
(PerCommitmentPoint -> PerCommitmentPoint -> Ordering)
-> (PerCommitmentPoint -> PerCommitmentPoint -> Bool)
-> (PerCommitmentPoint -> PerCommitmentPoint -> Bool)
-> (PerCommitmentPoint -> PerCommitmentPoint -> Bool)
-> (PerCommitmentPoint -> PerCommitmentPoint -> Bool)
-> (PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint)
-> (PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint)
-> Ord PerCommitmentPoint
PerCommitmentPoint -> PerCommitmentPoint -> Bool
PerCommitmentPoint -> PerCommitmentPoint -> Ordering
PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PerCommitmentPoint -> PerCommitmentPoint -> Ordering
compare :: PerCommitmentPoint -> PerCommitmentPoint -> Ordering
$c< :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
< :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
$c<= :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
<= :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
$c> :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
> :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
$c>= :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
>= :: PerCommitmentPoint -> PerCommitmentPoint -> Bool
$cmax :: PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint
max :: PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint
$cmin :: PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint
min :: PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint
Ord, Int -> PerCommitmentPoint -> ShowS
[PerCommitmentPoint] -> ShowS
PerCommitmentPoint -> String
(Int -> PerCommitmentPoint -> ShowS)
-> (PerCommitmentPoint -> String)
-> ([PerCommitmentPoint] -> ShowS)
-> Show PerCommitmentPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerCommitmentPoint -> ShowS
showsPrec :: Int -> PerCommitmentPoint -> ShowS
$cshow :: PerCommitmentPoint -> String
show :: PerCommitmentPoint -> String
$cshowList :: [PerCommitmentPoint] -> ShowS
showList :: [PerCommitmentPoint] -> ShowS
Show, (forall x. PerCommitmentPoint -> Rep PerCommitmentPoint x)
-> (forall x. Rep PerCommitmentPoint x -> PerCommitmentPoint)
-> Generic PerCommitmentPoint
forall x. Rep PerCommitmentPoint x -> PerCommitmentPoint
forall x. PerCommitmentPoint -> Rep PerCommitmentPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerCommitmentPoint -> Rep PerCommitmentPoint x
from :: forall x. PerCommitmentPoint -> Rep PerCommitmentPoint x
$cto :: forall x. Rep PerCommitmentPoint x -> PerCommitmentPoint
to :: forall x. Rep PerCommitmentPoint x -> PerCommitmentPoint
Generic)

-- | Per-commitment secret (32 bytes).
newtype PerCommitmentSecret = PerCommitmentSecret
  { PerCommitmentSecret -> ByteString
unPerCommitmentSecret :: BS.ByteString }
  deriving (PerCommitmentSecret -> PerCommitmentSecret -> Bool
(PerCommitmentSecret -> PerCommitmentSecret -> Bool)
-> (PerCommitmentSecret -> PerCommitmentSecret -> Bool)
-> Eq PerCommitmentSecret
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerCommitmentSecret -> PerCommitmentSecret -> Bool
== :: PerCommitmentSecret -> PerCommitmentSecret -> Bool
$c/= :: PerCommitmentSecret -> PerCommitmentSecret -> Bool
/= :: PerCommitmentSecret -> PerCommitmentSecret -> Bool
Eq, (forall x. PerCommitmentSecret -> Rep PerCommitmentSecret x)
-> (forall x. Rep PerCommitmentSecret x -> PerCommitmentSecret)
-> Generic PerCommitmentSecret
forall x. Rep PerCommitmentSecret x -> PerCommitmentSecret
forall x. PerCommitmentSecret -> Rep PerCommitmentSecret x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerCommitmentSecret -> Rep PerCommitmentSecret x
from :: forall x. PerCommitmentSecret -> Rep PerCommitmentSecret x
$cto :: forall x. Rep PerCommitmentSecret x -> PerCommitmentSecret
to :: forall x. Rep PerCommitmentSecret x -> PerCommitmentSecret
Generic)

instance Show PerCommitmentSecret where
  show :: PerCommitmentSecret -> String
show PerCommitmentSecret
_ = String
"PerCommitmentSecret <redacted>"

-- | Parse a 32-byte per-commitment secret.
--
-- Returns Nothing if the input is not exactly 32 bytes.
per_commitment_secret :: BS.ByteString -> Maybe PerCommitmentSecret
per_commitment_secret :: ByteString -> Maybe PerCommitmentSecret
per_commitment_secret ByteString
bs
  | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = PerCommitmentSecret -> Maybe PerCommitmentSecret
forall a. a -> Maybe a
Just (ByteString -> PerCommitmentSecret
PerCommitmentSecret ByteString
bs)
  | Bool
otherwise = Maybe PerCommitmentSecret
forall a. Maybe a
Nothing
{-# INLINE per_commitment_secret #-}

-- | Revocation basepoint.
newtype RevocationBasepoint = RevocationBasepoint
  { RevocationBasepoint -> Point
unRevocationBasepoint :: Point }
  deriving (RevocationBasepoint -> RevocationBasepoint -> Bool
(RevocationBasepoint -> RevocationBasepoint -> Bool)
-> (RevocationBasepoint -> RevocationBasepoint -> Bool)
-> Eq RevocationBasepoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RevocationBasepoint -> RevocationBasepoint -> Bool
== :: RevocationBasepoint -> RevocationBasepoint -> Bool
$c/= :: RevocationBasepoint -> RevocationBasepoint -> Bool
/= :: RevocationBasepoint -> RevocationBasepoint -> Bool
Eq, Eq RevocationBasepoint
Eq RevocationBasepoint =>
(RevocationBasepoint -> RevocationBasepoint -> Ordering)
-> (RevocationBasepoint -> RevocationBasepoint -> Bool)
-> (RevocationBasepoint -> RevocationBasepoint -> Bool)
-> (RevocationBasepoint -> RevocationBasepoint -> Bool)
-> (RevocationBasepoint -> RevocationBasepoint -> Bool)
-> (RevocationBasepoint
    -> RevocationBasepoint -> RevocationBasepoint)
-> (RevocationBasepoint
    -> RevocationBasepoint -> RevocationBasepoint)
-> Ord RevocationBasepoint
RevocationBasepoint -> RevocationBasepoint -> Bool
RevocationBasepoint -> RevocationBasepoint -> Ordering
RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RevocationBasepoint -> RevocationBasepoint -> Ordering
compare :: RevocationBasepoint -> RevocationBasepoint -> Ordering
$c< :: RevocationBasepoint -> RevocationBasepoint -> Bool
< :: RevocationBasepoint -> RevocationBasepoint -> Bool
$c<= :: RevocationBasepoint -> RevocationBasepoint -> Bool
<= :: RevocationBasepoint -> RevocationBasepoint -> Bool
$c> :: RevocationBasepoint -> RevocationBasepoint -> Bool
> :: RevocationBasepoint -> RevocationBasepoint -> Bool
$c>= :: RevocationBasepoint -> RevocationBasepoint -> Bool
>= :: RevocationBasepoint -> RevocationBasepoint -> Bool
$cmax :: RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint
max :: RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint
$cmin :: RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint
min :: RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint
Ord, Int -> RevocationBasepoint -> ShowS
[RevocationBasepoint] -> ShowS
RevocationBasepoint -> String
(Int -> RevocationBasepoint -> ShowS)
-> (RevocationBasepoint -> String)
-> ([RevocationBasepoint] -> ShowS)
-> Show RevocationBasepoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RevocationBasepoint -> ShowS
showsPrec :: Int -> RevocationBasepoint -> ShowS
$cshow :: RevocationBasepoint -> String
show :: RevocationBasepoint -> String
$cshowList :: [RevocationBasepoint] -> ShowS
showList :: [RevocationBasepoint] -> ShowS
Show, (forall x. RevocationBasepoint -> Rep RevocationBasepoint x)
-> (forall x. Rep RevocationBasepoint x -> RevocationBasepoint)
-> Generic RevocationBasepoint
forall x. Rep RevocationBasepoint x -> RevocationBasepoint
forall x. RevocationBasepoint -> Rep RevocationBasepoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RevocationBasepoint -> Rep RevocationBasepoint x
from :: forall x. RevocationBasepoint -> Rep RevocationBasepoint x
$cto :: forall x. Rep RevocationBasepoint x -> RevocationBasepoint
to :: forall x. Rep RevocationBasepoint x -> RevocationBasepoint
Generic)

-- | Payment basepoint.
newtype PaymentBasepoint = PaymentBasepoint
  { PaymentBasepoint -> Point
unPaymentBasepoint :: Point }
  deriving (PaymentBasepoint -> PaymentBasepoint -> Bool
(PaymentBasepoint -> PaymentBasepoint -> Bool)
-> (PaymentBasepoint -> PaymentBasepoint -> Bool)
-> Eq PaymentBasepoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaymentBasepoint -> PaymentBasepoint -> Bool
== :: PaymentBasepoint -> PaymentBasepoint -> Bool
$c/= :: PaymentBasepoint -> PaymentBasepoint -> Bool
/= :: PaymentBasepoint -> PaymentBasepoint -> Bool
Eq, Eq PaymentBasepoint
Eq PaymentBasepoint =>
(PaymentBasepoint -> PaymentBasepoint -> Ordering)
-> (PaymentBasepoint -> PaymentBasepoint -> Bool)
-> (PaymentBasepoint -> PaymentBasepoint -> Bool)
-> (PaymentBasepoint -> PaymentBasepoint -> Bool)
-> (PaymentBasepoint -> PaymentBasepoint -> Bool)
-> (PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint)
-> (PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint)
-> Ord PaymentBasepoint
PaymentBasepoint -> PaymentBasepoint -> Bool
PaymentBasepoint -> PaymentBasepoint -> Ordering
PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PaymentBasepoint -> PaymentBasepoint -> Ordering
compare :: PaymentBasepoint -> PaymentBasepoint -> Ordering
$c< :: PaymentBasepoint -> PaymentBasepoint -> Bool
< :: PaymentBasepoint -> PaymentBasepoint -> Bool
$c<= :: PaymentBasepoint -> PaymentBasepoint -> Bool
<= :: PaymentBasepoint -> PaymentBasepoint -> Bool
$c> :: PaymentBasepoint -> PaymentBasepoint -> Bool
> :: PaymentBasepoint -> PaymentBasepoint -> Bool
$c>= :: PaymentBasepoint -> PaymentBasepoint -> Bool
>= :: PaymentBasepoint -> PaymentBasepoint -> Bool
$cmax :: PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint
max :: PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint
$cmin :: PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint
min :: PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint
Ord, Int -> PaymentBasepoint -> ShowS
[PaymentBasepoint] -> ShowS
PaymentBasepoint -> String
(Int -> PaymentBasepoint -> ShowS)
-> (PaymentBasepoint -> String)
-> ([PaymentBasepoint] -> ShowS)
-> Show PaymentBasepoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaymentBasepoint -> ShowS
showsPrec :: Int -> PaymentBasepoint -> ShowS
$cshow :: PaymentBasepoint -> String
show :: PaymentBasepoint -> String
$cshowList :: [PaymentBasepoint] -> ShowS
showList :: [PaymentBasepoint] -> ShowS
Show, (forall x. PaymentBasepoint -> Rep PaymentBasepoint x)
-> (forall x. Rep PaymentBasepoint x -> PaymentBasepoint)
-> Generic PaymentBasepoint
forall x. Rep PaymentBasepoint x -> PaymentBasepoint
forall x. PaymentBasepoint -> Rep PaymentBasepoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PaymentBasepoint -> Rep PaymentBasepoint x
from :: forall x. PaymentBasepoint -> Rep PaymentBasepoint x
$cto :: forall x. Rep PaymentBasepoint x -> PaymentBasepoint
to :: forall x. Rep PaymentBasepoint x -> PaymentBasepoint
Generic)

-- | Delayed payment basepoint.
newtype DelayedPaymentBasepoint = DelayedPaymentBasepoint
  { DelayedPaymentBasepoint -> Point
unDelayedPaymentBasepoint :: Point }
  deriving (DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
(DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool)
-> (DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool)
-> Eq DelayedPaymentBasepoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
== :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
$c/= :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
/= :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
Eq, Eq DelayedPaymentBasepoint
Eq DelayedPaymentBasepoint =>
(DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Ordering)
-> (DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool)
-> (DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool)
-> (DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool)
-> (DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool)
-> (DelayedPaymentBasepoint
    -> DelayedPaymentBasepoint -> DelayedPaymentBasepoint)
-> (DelayedPaymentBasepoint
    -> DelayedPaymentBasepoint -> DelayedPaymentBasepoint)
-> Ord DelayedPaymentBasepoint
DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Ordering
DelayedPaymentBasepoint
-> DelayedPaymentBasepoint -> DelayedPaymentBasepoint
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Ordering
compare :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Ordering
$c< :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
< :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
$c<= :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
<= :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
$c> :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
> :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
$c>= :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
>= :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool
$cmax :: DelayedPaymentBasepoint
-> DelayedPaymentBasepoint -> DelayedPaymentBasepoint
max :: DelayedPaymentBasepoint
-> DelayedPaymentBasepoint -> DelayedPaymentBasepoint
$cmin :: DelayedPaymentBasepoint
-> DelayedPaymentBasepoint -> DelayedPaymentBasepoint
min :: DelayedPaymentBasepoint
-> DelayedPaymentBasepoint -> DelayedPaymentBasepoint
Ord, Int -> DelayedPaymentBasepoint -> ShowS
[DelayedPaymentBasepoint] -> ShowS
DelayedPaymentBasepoint -> String
(Int -> DelayedPaymentBasepoint -> ShowS)
-> (DelayedPaymentBasepoint -> String)
-> ([DelayedPaymentBasepoint] -> ShowS)
-> Show DelayedPaymentBasepoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DelayedPaymentBasepoint -> ShowS
showsPrec :: Int -> DelayedPaymentBasepoint -> ShowS
$cshow :: DelayedPaymentBasepoint -> String
show :: DelayedPaymentBasepoint -> String
$cshowList :: [DelayedPaymentBasepoint] -> ShowS
showList :: [DelayedPaymentBasepoint] -> ShowS
Show, (forall x.
 DelayedPaymentBasepoint -> Rep DelayedPaymentBasepoint x)
-> (forall x.
    Rep DelayedPaymentBasepoint x -> DelayedPaymentBasepoint)
-> Generic DelayedPaymentBasepoint
forall x. Rep DelayedPaymentBasepoint x -> DelayedPaymentBasepoint
forall x. DelayedPaymentBasepoint -> Rep DelayedPaymentBasepoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DelayedPaymentBasepoint -> Rep DelayedPaymentBasepoint x
from :: forall x. DelayedPaymentBasepoint -> Rep DelayedPaymentBasepoint x
$cto :: forall x. Rep DelayedPaymentBasepoint x -> DelayedPaymentBasepoint
to :: forall x. Rep DelayedPaymentBasepoint x -> DelayedPaymentBasepoint
Generic)

-- | HTLC basepoint.
newtype HtlcBasepoint = HtlcBasepoint { HtlcBasepoint -> Point
unHtlcBasepoint :: Point }
  deriving (HtlcBasepoint -> HtlcBasepoint -> Bool
(HtlcBasepoint -> HtlcBasepoint -> Bool)
-> (HtlcBasepoint -> HtlcBasepoint -> Bool) -> Eq HtlcBasepoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HtlcBasepoint -> HtlcBasepoint -> Bool
== :: HtlcBasepoint -> HtlcBasepoint -> Bool
$c/= :: HtlcBasepoint -> HtlcBasepoint -> Bool
/= :: HtlcBasepoint -> HtlcBasepoint -> Bool
Eq, Eq HtlcBasepoint
Eq HtlcBasepoint =>
(HtlcBasepoint -> HtlcBasepoint -> Ordering)
-> (HtlcBasepoint -> HtlcBasepoint -> Bool)
-> (HtlcBasepoint -> HtlcBasepoint -> Bool)
-> (HtlcBasepoint -> HtlcBasepoint -> Bool)
-> (HtlcBasepoint -> HtlcBasepoint -> Bool)
-> (HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint)
-> (HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint)
-> Ord HtlcBasepoint
HtlcBasepoint -> HtlcBasepoint -> Bool
HtlcBasepoint -> HtlcBasepoint -> Ordering
HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: HtlcBasepoint -> HtlcBasepoint -> Ordering
compare :: HtlcBasepoint -> HtlcBasepoint -> Ordering
$c< :: HtlcBasepoint -> HtlcBasepoint -> Bool
< :: HtlcBasepoint -> HtlcBasepoint -> Bool
$c<= :: HtlcBasepoint -> HtlcBasepoint -> Bool
<= :: HtlcBasepoint -> HtlcBasepoint -> Bool
$c> :: HtlcBasepoint -> HtlcBasepoint -> Bool
> :: HtlcBasepoint -> HtlcBasepoint -> Bool
$c>= :: HtlcBasepoint -> HtlcBasepoint -> Bool
>= :: HtlcBasepoint -> HtlcBasepoint -> Bool
$cmax :: HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint
max :: HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint
$cmin :: HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint
min :: HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint
Ord, Int -> HtlcBasepoint -> ShowS
[HtlcBasepoint] -> ShowS
HtlcBasepoint -> String
(Int -> HtlcBasepoint -> ShowS)
-> (HtlcBasepoint -> String)
-> ([HtlcBasepoint] -> ShowS)
-> Show HtlcBasepoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HtlcBasepoint -> ShowS
showsPrec :: Int -> HtlcBasepoint -> ShowS
$cshow :: HtlcBasepoint -> String
show :: HtlcBasepoint -> String
$cshowList :: [HtlcBasepoint] -> ShowS
showList :: [HtlcBasepoint] -> ShowS
Show, (forall x. HtlcBasepoint -> Rep HtlcBasepoint x)
-> (forall x. Rep HtlcBasepoint x -> HtlcBasepoint)
-> Generic HtlcBasepoint
forall x. Rep HtlcBasepoint x -> HtlcBasepoint
forall x. HtlcBasepoint -> Rep HtlcBasepoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HtlcBasepoint -> Rep HtlcBasepoint x
from :: forall x. HtlcBasepoint -> Rep HtlcBasepoint x
$cto :: forall x. Rep HtlcBasepoint x -> HtlcBasepoint
to :: forall x. Rep HtlcBasepoint x -> HtlcBasepoint
Generic)

-- | Collection of all basepoints for one party.
data Basepoints = Basepoints
  { Basepoints -> RevocationBasepoint
bp_revocation      :: !RevocationBasepoint
  , Basepoints -> PaymentBasepoint
bp_payment         :: !PaymentBasepoint
  , Basepoints -> DelayedPaymentBasepoint
bp_delayed_payment :: !DelayedPaymentBasepoint
  , Basepoints -> HtlcBasepoint
bp_htlc            :: !HtlcBasepoint
  } deriving (Basepoints -> Basepoints -> Bool
(Basepoints -> Basepoints -> Bool)
-> (Basepoints -> Basepoints -> Bool) -> Eq Basepoints
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Basepoints -> Basepoints -> Bool
== :: Basepoints -> Basepoints -> Bool
$c/= :: Basepoints -> Basepoints -> Bool
/= :: Basepoints -> Basepoints -> Bool
Eq, Int -> Basepoints -> ShowS
[Basepoints] -> ShowS
Basepoints -> String
(Int -> Basepoints -> ShowS)
-> (Basepoints -> String)
-> ([Basepoints] -> ShowS)
-> Show Basepoints
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Basepoints -> ShowS
showsPrec :: Int -> Basepoints -> ShowS
$cshow :: Basepoints -> String
show :: Basepoints -> String
$cshowList :: [Basepoints] -> ShowS
showList :: [Basepoints] -> ShowS
Show, (forall x. Basepoints -> Rep Basepoints x)
-> (forall x. Rep Basepoints x -> Basepoints) -> Generic Basepoints
forall x. Rep Basepoints x -> Basepoints
forall x. Basepoints -> Rep Basepoints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Basepoints -> Rep Basepoints x
from :: forall x. Basepoints -> Rep Basepoints x
$cto :: forall x. Rep Basepoints x -> Basepoints
to :: forall x. Rep Basepoints x -> Basepoints
Generic)

-- derived keys ----------------------------------------------------------------

-- | Local pubkey (derived from payment_basepoint + per_commitment_point).
newtype LocalPubkey = LocalPubkey { LocalPubkey -> Pubkey
unLocalPubkey :: Pubkey }
  deriving (LocalPubkey -> LocalPubkey -> Bool
(LocalPubkey -> LocalPubkey -> Bool)
-> (LocalPubkey -> LocalPubkey -> Bool) -> Eq LocalPubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LocalPubkey -> LocalPubkey -> Bool
== :: LocalPubkey -> LocalPubkey -> Bool
$c/= :: LocalPubkey -> LocalPubkey -> Bool
/= :: LocalPubkey -> LocalPubkey -> Bool
Eq, Eq LocalPubkey
Eq LocalPubkey =>
(LocalPubkey -> LocalPubkey -> Ordering)
-> (LocalPubkey -> LocalPubkey -> Bool)
-> (LocalPubkey -> LocalPubkey -> Bool)
-> (LocalPubkey -> LocalPubkey -> Bool)
-> (LocalPubkey -> LocalPubkey -> Bool)
-> (LocalPubkey -> LocalPubkey -> LocalPubkey)
-> (LocalPubkey -> LocalPubkey -> LocalPubkey)
-> Ord LocalPubkey
LocalPubkey -> LocalPubkey -> Bool
LocalPubkey -> LocalPubkey -> Ordering
LocalPubkey -> LocalPubkey -> LocalPubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: LocalPubkey -> LocalPubkey -> Ordering
compare :: LocalPubkey -> LocalPubkey -> Ordering
$c< :: LocalPubkey -> LocalPubkey -> Bool
< :: LocalPubkey -> LocalPubkey -> Bool
$c<= :: LocalPubkey -> LocalPubkey -> Bool
<= :: LocalPubkey -> LocalPubkey -> Bool
$c> :: LocalPubkey -> LocalPubkey -> Bool
> :: LocalPubkey -> LocalPubkey -> Bool
$c>= :: LocalPubkey -> LocalPubkey -> Bool
>= :: LocalPubkey -> LocalPubkey -> Bool
$cmax :: LocalPubkey -> LocalPubkey -> LocalPubkey
max :: LocalPubkey -> LocalPubkey -> LocalPubkey
$cmin :: LocalPubkey -> LocalPubkey -> LocalPubkey
min :: LocalPubkey -> LocalPubkey -> LocalPubkey
Ord, Int -> LocalPubkey -> ShowS
[LocalPubkey] -> ShowS
LocalPubkey -> String
(Int -> LocalPubkey -> ShowS)
-> (LocalPubkey -> String)
-> ([LocalPubkey] -> ShowS)
-> Show LocalPubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocalPubkey -> ShowS
showsPrec :: Int -> LocalPubkey -> ShowS
$cshow :: LocalPubkey -> String
show :: LocalPubkey -> String
$cshowList :: [LocalPubkey] -> ShowS
showList :: [LocalPubkey] -> ShowS
Show, (forall x. LocalPubkey -> Rep LocalPubkey x)
-> (forall x. Rep LocalPubkey x -> LocalPubkey)
-> Generic LocalPubkey
forall x. Rep LocalPubkey x -> LocalPubkey
forall x. LocalPubkey -> Rep LocalPubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LocalPubkey -> Rep LocalPubkey x
from :: forall x. LocalPubkey -> Rep LocalPubkey x
$cto :: forall x. Rep LocalPubkey x -> LocalPubkey
to :: forall x. Rep LocalPubkey x -> LocalPubkey
Generic)

-- | Remote pubkey (simply the remote's payment_basepoint).
newtype RemotePubkey = RemotePubkey { RemotePubkey -> Pubkey
unRemotePubkey :: Pubkey }
  deriving (RemotePubkey -> RemotePubkey -> Bool
(RemotePubkey -> RemotePubkey -> Bool)
-> (RemotePubkey -> RemotePubkey -> Bool) -> Eq RemotePubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemotePubkey -> RemotePubkey -> Bool
== :: RemotePubkey -> RemotePubkey -> Bool
$c/= :: RemotePubkey -> RemotePubkey -> Bool
/= :: RemotePubkey -> RemotePubkey -> Bool
Eq, Eq RemotePubkey
Eq RemotePubkey =>
(RemotePubkey -> RemotePubkey -> Ordering)
-> (RemotePubkey -> RemotePubkey -> Bool)
-> (RemotePubkey -> RemotePubkey -> Bool)
-> (RemotePubkey -> RemotePubkey -> Bool)
-> (RemotePubkey -> RemotePubkey -> Bool)
-> (RemotePubkey -> RemotePubkey -> RemotePubkey)
-> (RemotePubkey -> RemotePubkey -> RemotePubkey)
-> Ord RemotePubkey
RemotePubkey -> RemotePubkey -> Bool
RemotePubkey -> RemotePubkey -> Ordering
RemotePubkey -> RemotePubkey -> RemotePubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RemotePubkey -> RemotePubkey -> Ordering
compare :: RemotePubkey -> RemotePubkey -> Ordering
$c< :: RemotePubkey -> RemotePubkey -> Bool
< :: RemotePubkey -> RemotePubkey -> Bool
$c<= :: RemotePubkey -> RemotePubkey -> Bool
<= :: RemotePubkey -> RemotePubkey -> Bool
$c> :: RemotePubkey -> RemotePubkey -> Bool
> :: RemotePubkey -> RemotePubkey -> Bool
$c>= :: RemotePubkey -> RemotePubkey -> Bool
>= :: RemotePubkey -> RemotePubkey -> Bool
$cmax :: RemotePubkey -> RemotePubkey -> RemotePubkey
max :: RemotePubkey -> RemotePubkey -> RemotePubkey
$cmin :: RemotePubkey -> RemotePubkey -> RemotePubkey
min :: RemotePubkey -> RemotePubkey -> RemotePubkey
Ord, Int -> RemotePubkey -> ShowS
[RemotePubkey] -> ShowS
RemotePubkey -> String
(Int -> RemotePubkey -> ShowS)
-> (RemotePubkey -> String)
-> ([RemotePubkey] -> ShowS)
-> Show RemotePubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemotePubkey -> ShowS
showsPrec :: Int -> RemotePubkey -> ShowS
$cshow :: RemotePubkey -> String
show :: RemotePubkey -> String
$cshowList :: [RemotePubkey] -> ShowS
showList :: [RemotePubkey] -> ShowS
Show, (forall x. RemotePubkey -> Rep RemotePubkey x)
-> (forall x. Rep RemotePubkey x -> RemotePubkey)
-> Generic RemotePubkey
forall x. Rep RemotePubkey x -> RemotePubkey
forall x. RemotePubkey -> Rep RemotePubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RemotePubkey -> Rep RemotePubkey x
from :: forall x. RemotePubkey -> Rep RemotePubkey x
$cto :: forall x. Rep RemotePubkey x -> RemotePubkey
to :: forall x. Rep RemotePubkey x -> RemotePubkey
Generic)

-- | Local delayed pubkey.
newtype LocalDelayedPubkey = LocalDelayedPubkey
  { LocalDelayedPubkey -> Pubkey
unLocalDelayedPubkey :: Pubkey }
  deriving (LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
(LocalDelayedPubkey -> LocalDelayedPubkey -> Bool)
-> (LocalDelayedPubkey -> LocalDelayedPubkey -> Bool)
-> Eq LocalDelayedPubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
== :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
$c/= :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
/= :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
Eq, Eq LocalDelayedPubkey
Eq LocalDelayedPubkey =>
(LocalDelayedPubkey -> LocalDelayedPubkey -> Ordering)
-> (LocalDelayedPubkey -> LocalDelayedPubkey -> Bool)
-> (LocalDelayedPubkey -> LocalDelayedPubkey -> Bool)
-> (LocalDelayedPubkey -> LocalDelayedPubkey -> Bool)
-> (LocalDelayedPubkey -> LocalDelayedPubkey -> Bool)
-> (LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey)
-> (LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey)
-> Ord LocalDelayedPubkey
LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
LocalDelayedPubkey -> LocalDelayedPubkey -> Ordering
LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: LocalDelayedPubkey -> LocalDelayedPubkey -> Ordering
compare :: LocalDelayedPubkey -> LocalDelayedPubkey -> Ordering
$c< :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
< :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
$c<= :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
<= :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
$c> :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
> :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
$c>= :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
>= :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool
$cmax :: LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey
max :: LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey
$cmin :: LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey
min :: LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey
Ord, Int -> LocalDelayedPubkey -> ShowS
[LocalDelayedPubkey] -> ShowS
LocalDelayedPubkey -> String
(Int -> LocalDelayedPubkey -> ShowS)
-> (LocalDelayedPubkey -> String)
-> ([LocalDelayedPubkey] -> ShowS)
-> Show LocalDelayedPubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocalDelayedPubkey -> ShowS
showsPrec :: Int -> LocalDelayedPubkey -> ShowS
$cshow :: LocalDelayedPubkey -> String
show :: LocalDelayedPubkey -> String
$cshowList :: [LocalDelayedPubkey] -> ShowS
showList :: [LocalDelayedPubkey] -> ShowS
Show, (forall x. LocalDelayedPubkey -> Rep LocalDelayedPubkey x)
-> (forall x. Rep LocalDelayedPubkey x -> LocalDelayedPubkey)
-> Generic LocalDelayedPubkey
forall x. Rep LocalDelayedPubkey x -> LocalDelayedPubkey
forall x. LocalDelayedPubkey -> Rep LocalDelayedPubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LocalDelayedPubkey -> Rep LocalDelayedPubkey x
from :: forall x. LocalDelayedPubkey -> Rep LocalDelayedPubkey x
$cto :: forall x. Rep LocalDelayedPubkey x -> LocalDelayedPubkey
to :: forall x. Rep LocalDelayedPubkey x -> LocalDelayedPubkey
Generic)

-- | Remote delayed pubkey.
newtype RemoteDelayedPubkey = RemoteDelayedPubkey
  { RemoteDelayedPubkey -> Pubkey
unRemoteDelayedPubkey :: Pubkey }
  deriving (RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
(RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool)
-> (RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool)
-> Eq RemoteDelayedPubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
== :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
$c/= :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
/= :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
Eq, Eq RemoteDelayedPubkey
Eq RemoteDelayedPubkey =>
(RemoteDelayedPubkey -> RemoteDelayedPubkey -> Ordering)
-> (RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool)
-> (RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool)
-> (RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool)
-> (RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool)
-> (RemoteDelayedPubkey
    -> RemoteDelayedPubkey -> RemoteDelayedPubkey)
-> (RemoteDelayedPubkey
    -> RemoteDelayedPubkey -> RemoteDelayedPubkey)
-> Ord RemoteDelayedPubkey
RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
RemoteDelayedPubkey -> RemoteDelayedPubkey -> Ordering
RemoteDelayedPubkey -> RemoteDelayedPubkey -> RemoteDelayedPubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Ordering
compare :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Ordering
$c< :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
< :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
$c<= :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
<= :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
$c> :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
> :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
$c>= :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
>= :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool
$cmax :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> RemoteDelayedPubkey
max :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> RemoteDelayedPubkey
$cmin :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> RemoteDelayedPubkey
min :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> RemoteDelayedPubkey
Ord, Int -> RemoteDelayedPubkey -> ShowS
[RemoteDelayedPubkey] -> ShowS
RemoteDelayedPubkey -> String
(Int -> RemoteDelayedPubkey -> ShowS)
-> (RemoteDelayedPubkey -> String)
-> ([RemoteDelayedPubkey] -> ShowS)
-> Show RemoteDelayedPubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoteDelayedPubkey -> ShowS
showsPrec :: Int -> RemoteDelayedPubkey -> ShowS
$cshow :: RemoteDelayedPubkey -> String
show :: RemoteDelayedPubkey -> String
$cshowList :: [RemoteDelayedPubkey] -> ShowS
showList :: [RemoteDelayedPubkey] -> ShowS
Show, (forall x. RemoteDelayedPubkey -> Rep RemoteDelayedPubkey x)
-> (forall x. Rep RemoteDelayedPubkey x -> RemoteDelayedPubkey)
-> Generic RemoteDelayedPubkey
forall x. Rep RemoteDelayedPubkey x -> RemoteDelayedPubkey
forall x. RemoteDelayedPubkey -> Rep RemoteDelayedPubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RemoteDelayedPubkey -> Rep RemoteDelayedPubkey x
from :: forall x. RemoteDelayedPubkey -> Rep RemoteDelayedPubkey x
$cto :: forall x. Rep RemoteDelayedPubkey x -> RemoteDelayedPubkey
to :: forall x. Rep RemoteDelayedPubkey x -> RemoteDelayedPubkey
Generic)

-- | Local HTLC pubkey.
newtype LocalHtlcPubkey = LocalHtlcPubkey { LocalHtlcPubkey -> Pubkey
unLocalHtlcPubkey :: Pubkey }
  deriving (LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
(LocalHtlcPubkey -> LocalHtlcPubkey -> Bool)
-> (LocalHtlcPubkey -> LocalHtlcPubkey -> Bool)
-> Eq LocalHtlcPubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
== :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
$c/= :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
/= :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
Eq, Eq LocalHtlcPubkey
Eq LocalHtlcPubkey =>
(LocalHtlcPubkey -> LocalHtlcPubkey -> Ordering)
-> (LocalHtlcPubkey -> LocalHtlcPubkey -> Bool)
-> (LocalHtlcPubkey -> LocalHtlcPubkey -> Bool)
-> (LocalHtlcPubkey -> LocalHtlcPubkey -> Bool)
-> (LocalHtlcPubkey -> LocalHtlcPubkey -> Bool)
-> (LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey)
-> (LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey)
-> Ord LocalHtlcPubkey
LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
LocalHtlcPubkey -> LocalHtlcPubkey -> Ordering
LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: LocalHtlcPubkey -> LocalHtlcPubkey -> Ordering
compare :: LocalHtlcPubkey -> LocalHtlcPubkey -> Ordering
$c< :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
< :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
$c<= :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
<= :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
$c> :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
> :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
$c>= :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
>= :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool
$cmax :: LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey
max :: LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey
$cmin :: LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey
min :: LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey
Ord, Int -> LocalHtlcPubkey -> ShowS
[LocalHtlcPubkey] -> ShowS
LocalHtlcPubkey -> String
(Int -> LocalHtlcPubkey -> ShowS)
-> (LocalHtlcPubkey -> String)
-> ([LocalHtlcPubkey] -> ShowS)
-> Show LocalHtlcPubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocalHtlcPubkey -> ShowS
showsPrec :: Int -> LocalHtlcPubkey -> ShowS
$cshow :: LocalHtlcPubkey -> String
show :: LocalHtlcPubkey -> String
$cshowList :: [LocalHtlcPubkey] -> ShowS
showList :: [LocalHtlcPubkey] -> ShowS
Show, (forall x. LocalHtlcPubkey -> Rep LocalHtlcPubkey x)
-> (forall x. Rep LocalHtlcPubkey x -> LocalHtlcPubkey)
-> Generic LocalHtlcPubkey
forall x. Rep LocalHtlcPubkey x -> LocalHtlcPubkey
forall x. LocalHtlcPubkey -> Rep LocalHtlcPubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LocalHtlcPubkey -> Rep LocalHtlcPubkey x
from :: forall x. LocalHtlcPubkey -> Rep LocalHtlcPubkey x
$cto :: forall x. Rep LocalHtlcPubkey x -> LocalHtlcPubkey
to :: forall x. Rep LocalHtlcPubkey x -> LocalHtlcPubkey
Generic)

-- | Remote HTLC pubkey.
newtype RemoteHtlcPubkey = RemoteHtlcPubkey { RemoteHtlcPubkey -> Pubkey
unRemoteHtlcPubkey :: Pubkey }
  deriving (RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
(RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool)
-> (RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool)
-> Eq RemoteHtlcPubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
== :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
$c/= :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
/= :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
Eq, Eq RemoteHtlcPubkey
Eq RemoteHtlcPubkey =>
(RemoteHtlcPubkey -> RemoteHtlcPubkey -> Ordering)
-> (RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool)
-> (RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool)
-> (RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool)
-> (RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool)
-> (RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey)
-> (RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey)
-> Ord RemoteHtlcPubkey
RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
RemoteHtlcPubkey -> RemoteHtlcPubkey -> Ordering
RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Ordering
compare :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Ordering
$c< :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
< :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
$c<= :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
<= :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
$c> :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
> :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
$c>= :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
>= :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool
$cmax :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey
max :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey
$cmin :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey
min :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey
Ord, Int -> RemoteHtlcPubkey -> ShowS
[RemoteHtlcPubkey] -> ShowS
RemoteHtlcPubkey -> String
(Int -> RemoteHtlcPubkey -> ShowS)
-> (RemoteHtlcPubkey -> String)
-> ([RemoteHtlcPubkey] -> ShowS)
-> Show RemoteHtlcPubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoteHtlcPubkey -> ShowS
showsPrec :: Int -> RemoteHtlcPubkey -> ShowS
$cshow :: RemoteHtlcPubkey -> String
show :: RemoteHtlcPubkey -> String
$cshowList :: [RemoteHtlcPubkey] -> ShowS
showList :: [RemoteHtlcPubkey] -> ShowS
Show, (forall x. RemoteHtlcPubkey -> Rep RemoteHtlcPubkey x)
-> (forall x. Rep RemoteHtlcPubkey x -> RemoteHtlcPubkey)
-> Generic RemoteHtlcPubkey
forall x. Rep RemoteHtlcPubkey x -> RemoteHtlcPubkey
forall x. RemoteHtlcPubkey -> Rep RemoteHtlcPubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RemoteHtlcPubkey -> Rep RemoteHtlcPubkey x
from :: forall x. RemoteHtlcPubkey -> Rep RemoteHtlcPubkey x
$cto :: forall x. Rep RemoteHtlcPubkey x -> RemoteHtlcPubkey
to :: forall x. Rep RemoteHtlcPubkey x -> RemoteHtlcPubkey
Generic)

-- | Revocation pubkey (derived from revocation_basepoint + per_commitment).
newtype RevocationPubkey = RevocationPubkey { RevocationPubkey -> Pubkey
unRevocationPubkey :: Pubkey }
  deriving (RevocationPubkey -> RevocationPubkey -> Bool
(RevocationPubkey -> RevocationPubkey -> Bool)
-> (RevocationPubkey -> RevocationPubkey -> Bool)
-> Eq RevocationPubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RevocationPubkey -> RevocationPubkey -> Bool
== :: RevocationPubkey -> RevocationPubkey -> Bool
$c/= :: RevocationPubkey -> RevocationPubkey -> Bool
/= :: RevocationPubkey -> RevocationPubkey -> Bool
Eq, Eq RevocationPubkey
Eq RevocationPubkey =>
(RevocationPubkey -> RevocationPubkey -> Ordering)
-> (RevocationPubkey -> RevocationPubkey -> Bool)
-> (RevocationPubkey -> RevocationPubkey -> Bool)
-> (RevocationPubkey -> RevocationPubkey -> Bool)
-> (RevocationPubkey -> RevocationPubkey -> Bool)
-> (RevocationPubkey -> RevocationPubkey -> RevocationPubkey)
-> (RevocationPubkey -> RevocationPubkey -> RevocationPubkey)
-> Ord RevocationPubkey
RevocationPubkey -> RevocationPubkey -> Bool
RevocationPubkey -> RevocationPubkey -> Ordering
RevocationPubkey -> RevocationPubkey -> RevocationPubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RevocationPubkey -> RevocationPubkey -> Ordering
compare :: RevocationPubkey -> RevocationPubkey -> Ordering
$c< :: RevocationPubkey -> RevocationPubkey -> Bool
< :: RevocationPubkey -> RevocationPubkey -> Bool
$c<= :: RevocationPubkey -> RevocationPubkey -> Bool
<= :: RevocationPubkey -> RevocationPubkey -> Bool
$c> :: RevocationPubkey -> RevocationPubkey -> Bool
> :: RevocationPubkey -> RevocationPubkey -> Bool
$c>= :: RevocationPubkey -> RevocationPubkey -> Bool
>= :: RevocationPubkey -> RevocationPubkey -> Bool
$cmax :: RevocationPubkey -> RevocationPubkey -> RevocationPubkey
max :: RevocationPubkey -> RevocationPubkey -> RevocationPubkey
$cmin :: RevocationPubkey -> RevocationPubkey -> RevocationPubkey
min :: RevocationPubkey -> RevocationPubkey -> RevocationPubkey
Ord, Int -> RevocationPubkey -> ShowS
[RevocationPubkey] -> ShowS
RevocationPubkey -> String
(Int -> RevocationPubkey -> ShowS)
-> (RevocationPubkey -> String)
-> ([RevocationPubkey] -> ShowS)
-> Show RevocationPubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RevocationPubkey -> ShowS
showsPrec :: Int -> RevocationPubkey -> ShowS
$cshow :: RevocationPubkey -> String
show :: RevocationPubkey -> String
$cshowList :: [RevocationPubkey] -> ShowS
showList :: [RevocationPubkey] -> ShowS
Show, (forall x. RevocationPubkey -> Rep RevocationPubkey x)
-> (forall x. Rep RevocationPubkey x -> RevocationPubkey)
-> Generic RevocationPubkey
forall x. Rep RevocationPubkey x -> RevocationPubkey
forall x. RevocationPubkey -> Rep RevocationPubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RevocationPubkey -> Rep RevocationPubkey x
from :: forall x. RevocationPubkey -> Rep RevocationPubkey x
$cto :: forall x. Rep RevocationPubkey x -> RevocationPubkey
to :: forall x. Rep RevocationPubkey x -> RevocationPubkey
Generic)

-- | Funding pubkey (used in 2-of-2 multisig).
newtype FundingPubkey = FundingPubkey { FundingPubkey -> Pubkey
unFundingPubkey :: Pubkey }
  deriving (FundingPubkey -> FundingPubkey -> Bool
(FundingPubkey -> FundingPubkey -> Bool)
-> (FundingPubkey -> FundingPubkey -> Bool) -> Eq FundingPubkey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FundingPubkey -> FundingPubkey -> Bool
== :: FundingPubkey -> FundingPubkey -> Bool
$c/= :: FundingPubkey -> FundingPubkey -> Bool
/= :: FundingPubkey -> FundingPubkey -> Bool
Eq, Eq FundingPubkey
Eq FundingPubkey =>
(FundingPubkey -> FundingPubkey -> Ordering)
-> (FundingPubkey -> FundingPubkey -> Bool)
-> (FundingPubkey -> FundingPubkey -> Bool)
-> (FundingPubkey -> FundingPubkey -> Bool)
-> (FundingPubkey -> FundingPubkey -> Bool)
-> (FundingPubkey -> FundingPubkey -> FundingPubkey)
-> (FundingPubkey -> FundingPubkey -> FundingPubkey)
-> Ord FundingPubkey
FundingPubkey -> FundingPubkey -> Bool
FundingPubkey -> FundingPubkey -> Ordering
FundingPubkey -> FundingPubkey -> FundingPubkey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FundingPubkey -> FundingPubkey -> Ordering
compare :: FundingPubkey -> FundingPubkey -> Ordering
$c< :: FundingPubkey -> FundingPubkey -> Bool
< :: FundingPubkey -> FundingPubkey -> Bool
$c<= :: FundingPubkey -> FundingPubkey -> Bool
<= :: FundingPubkey -> FundingPubkey -> Bool
$c> :: FundingPubkey -> FundingPubkey -> Bool
> :: FundingPubkey -> FundingPubkey -> Bool
$c>= :: FundingPubkey -> FundingPubkey -> Bool
>= :: FundingPubkey -> FundingPubkey -> Bool
$cmax :: FundingPubkey -> FundingPubkey -> FundingPubkey
max :: FundingPubkey -> FundingPubkey -> FundingPubkey
$cmin :: FundingPubkey -> FundingPubkey -> FundingPubkey
min :: FundingPubkey -> FundingPubkey -> FundingPubkey
Ord, Int -> FundingPubkey -> ShowS
[FundingPubkey] -> ShowS
FundingPubkey -> String
(Int -> FundingPubkey -> ShowS)
-> (FundingPubkey -> String)
-> ([FundingPubkey] -> ShowS)
-> Show FundingPubkey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FundingPubkey -> ShowS
showsPrec :: Int -> FundingPubkey -> ShowS
$cshow :: FundingPubkey -> String
show :: FundingPubkey -> String
$cshowList :: [FundingPubkey] -> ShowS
showList :: [FundingPubkey] -> ShowS
Show, (forall x. FundingPubkey -> Rep FundingPubkey x)
-> (forall x. Rep FundingPubkey x -> FundingPubkey)
-> Generic FundingPubkey
forall x. Rep FundingPubkey x -> FundingPubkey
forall x. FundingPubkey -> Rep FundingPubkey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FundingPubkey -> Rep FundingPubkey x
from :: forall x. FundingPubkey -> Rep FundingPubkey x
$cto :: forall x. Rep FundingPubkey x -> FundingPubkey
to :: forall x. Rep FundingPubkey x -> FundingPubkey
Generic)

-- script and witness ----------------------------------------------------------

-- | Bitcoin script (serialized).
newtype Script = Script { Script -> ByteString
unScript :: BS.ByteString }
  deriving (Script -> Script -> Bool
(Script -> Script -> Bool)
-> (Script -> Script -> Bool) -> Eq Script
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Script -> Script -> Bool
== :: Script -> Script -> Bool
$c/= :: Script -> Script -> Bool
/= :: Script -> Script -> Bool
Eq, Eq Script
Eq Script =>
(Script -> Script -> Ordering)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Script)
-> (Script -> Script -> Script)
-> Ord Script
Script -> Script -> Bool
Script -> Script -> Ordering
Script -> Script -> Script
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Script -> Script -> Ordering
compare :: Script -> Script -> Ordering
$c< :: Script -> Script -> Bool
< :: Script -> Script -> Bool
$c<= :: Script -> Script -> Bool
<= :: Script -> Script -> Bool
$c> :: Script -> Script -> Bool
> :: Script -> Script -> Bool
$c>= :: Script -> Script -> Bool
>= :: Script -> Script -> Bool
$cmax :: Script -> Script -> Script
max :: Script -> Script -> Script
$cmin :: Script -> Script -> Script
min :: Script -> Script -> Script
Ord, Int -> Script -> ShowS
[Script] -> ShowS
Script -> String
(Int -> Script -> ShowS)
-> (Script -> String) -> ([Script] -> ShowS) -> Show Script
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Script -> ShowS
showsPrec :: Int -> Script -> ShowS
$cshow :: Script -> String
show :: Script -> String
$cshowList :: [Script] -> ShowS
showList :: [Script] -> ShowS
Show, (forall x. Script -> Rep Script x)
-> (forall x. Rep Script x -> Script) -> Generic Script
forall x. Rep Script x -> Script
forall x. Script -> Rep Script x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Script -> Rep Script x
from :: forall x. Script -> Rep Script x
$cto :: forall x. Rep Script x -> Script
to :: forall x. Rep Script x -> Script
Generic)

-- | Transaction witness stack.
newtype Witness = Witness { Witness -> [ByteString]
unWitness :: [BS.ByteString] }
  deriving (Witness -> Witness -> Bool
(Witness -> Witness -> Bool)
-> (Witness -> Witness -> Bool) -> Eq Witness
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Witness -> Witness -> Bool
== :: Witness -> Witness -> Bool
$c/= :: Witness -> Witness -> Bool
/= :: Witness -> Witness -> Bool
Eq, Eq Witness
Eq Witness =>
(Witness -> Witness -> Ordering)
-> (Witness -> Witness -> Bool)
-> (Witness -> Witness -> Bool)
-> (Witness -> Witness -> Bool)
-> (Witness -> Witness -> Bool)
-> (Witness -> Witness -> Witness)
-> (Witness -> Witness -> Witness)
-> Ord Witness
Witness -> Witness -> Bool
Witness -> Witness -> Ordering
Witness -> Witness -> Witness
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Witness -> Witness -> Ordering
compare :: Witness -> Witness -> Ordering
$c< :: Witness -> Witness -> Bool
< :: Witness -> Witness -> Bool
$c<= :: Witness -> Witness -> Bool
<= :: Witness -> Witness -> Bool
$c> :: Witness -> Witness -> Bool
> :: Witness -> Witness -> Bool
$c>= :: Witness -> Witness -> Bool
>= :: Witness -> Witness -> Bool
$cmax :: Witness -> Witness -> Witness
max :: Witness -> Witness -> Witness
$cmin :: Witness -> Witness -> Witness
min :: Witness -> Witness -> Witness
Ord, Int -> Witness -> ShowS
[Witness] -> ShowS
Witness -> String
(Int -> Witness -> ShowS)
-> (Witness -> String) -> ([Witness] -> ShowS) -> Show Witness
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Witness -> ShowS
showsPrec :: Int -> Witness -> ShowS
$cshow :: Witness -> String
show :: Witness -> String
$cshowList :: [Witness] -> ShowS
showList :: [Witness] -> ShowS
Show, (forall x. Witness -> Rep Witness x)
-> (forall x. Rep Witness x -> Witness) -> Generic Witness
forall x. Rep Witness x -> Witness
forall x. Witness -> Rep Witness x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Witness -> Rep Witness x
from :: forall x. Witness -> Rep Witness x
$cto :: forall x. Rep Witness x -> Witness
to :: forall x. Rep Witness x -> Witness
Generic)

-- channel options -------------------------------------------------------------

-- | Channel feature flags relevant to BOLT #3.
data ChannelFeatures = ChannelFeatures
  { ChannelFeatures -> Bool
cf_option_anchors :: !Bool
  } deriving (ChannelFeatures -> ChannelFeatures -> Bool
(ChannelFeatures -> ChannelFeatures -> Bool)
-> (ChannelFeatures -> ChannelFeatures -> Bool)
-> Eq ChannelFeatures
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChannelFeatures -> ChannelFeatures -> Bool
== :: ChannelFeatures -> ChannelFeatures -> Bool
$c/= :: ChannelFeatures -> ChannelFeatures -> Bool
/= :: ChannelFeatures -> ChannelFeatures -> Bool
Eq, Int -> ChannelFeatures -> ShowS
[ChannelFeatures] -> ShowS
ChannelFeatures -> String
(Int -> ChannelFeatures -> ShowS)
-> (ChannelFeatures -> String)
-> ([ChannelFeatures] -> ShowS)
-> Show ChannelFeatures
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChannelFeatures -> ShowS
showsPrec :: Int -> ChannelFeatures -> ShowS
$cshow :: ChannelFeatures -> String
show :: ChannelFeatures -> String
$cshowList :: [ChannelFeatures] -> ShowS
showList :: [ChannelFeatures] -> ShowS
Show, (forall x. ChannelFeatures -> Rep ChannelFeatures x)
-> (forall x. Rep ChannelFeatures x -> ChannelFeatures)
-> Generic ChannelFeatures
forall x. Rep ChannelFeatures x -> ChannelFeatures
forall x. ChannelFeatures -> Rep ChannelFeatures x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ChannelFeatures -> Rep ChannelFeatures x
from :: forall x. ChannelFeatures -> Rep ChannelFeatures x
$cto :: forall x. Rep ChannelFeatures x -> ChannelFeatures
to :: forall x. Rep ChannelFeatures x -> ChannelFeatures
Generic)

-- | Check if option_anchors is enabled.
has_anchors :: ChannelFeatures -> Bool
has_anchors :: ChannelFeatures -> Bool
has_anchors = ChannelFeatures -> Bool
cf_option_anchors
{-# INLINE has_anchors #-}

-- transaction weights (constants from spec) -----------------------------------

-- | Base commitment tx weight without option_anchors.
commitment_weight_no_anchors :: Word64
commitment_weight_no_anchors :: Word64
commitment_weight_no_anchors = Word64
724

-- | Base commitment tx weight with option_anchors.
commitment_weight_anchors :: Word64
commitment_weight_anchors :: Word64
commitment_weight_anchors = Word64
1124

-- | HTLC-timeout tx weight without option_anchors.
htlc_timeout_weight_no_anchors :: Word64
htlc_timeout_weight_no_anchors :: Word64
htlc_timeout_weight_no_anchors = Word64
663

-- | HTLC-timeout tx weight with option_anchors.
htlc_timeout_weight_anchors :: Word64
htlc_timeout_weight_anchors :: Word64
htlc_timeout_weight_anchors = Word64
666

-- | HTLC-success tx weight without option_anchors.
htlc_success_weight_no_anchors :: Word64
htlc_success_weight_no_anchors :: Word64
htlc_success_weight_no_anchors = Word64
703

-- | HTLC-success tx weight with option_anchors.
htlc_success_weight_anchors :: Word64
htlc_success_weight_anchors :: Word64
htlc_success_weight_anchors = Word64
706

-- | Weight added per HTLC output in commitment tx.
htlc_output_weight :: Word64
htlc_output_weight :: Word64
htlc_output_weight = Word64
172

-- dust thresholds (constants from Bitcoin Core) -------------------------------

-- | P2PKH dust threshold (546 satoshis).
dust_p2pkh :: Satoshi
dust_p2pkh :: Satoshi
dust_p2pkh = Word64 -> Satoshi
Satoshi Word64
546

-- | P2SH dust threshold (540 satoshis).
dust_p2sh :: Satoshi
dust_p2sh :: Satoshi
dust_p2sh = Word64 -> Satoshi
Satoshi Word64
540

-- | P2WPKH dust threshold (294 satoshis).
dust_p2wpkh :: Satoshi
dust_p2wpkh :: Satoshi
dust_p2wpkh = Word64 -> Satoshi
Satoshi Word64
294

-- | P2WSH dust threshold (330 satoshis).
dust_p2wsh :: Satoshi
dust_p2wsh :: Satoshi
dust_p2wsh = Word64 -> Satoshi
Satoshi Word64
330

-- | Fixed anchor output value (330 satoshis).
anchor_output_value :: Satoshi
anchor_output_value :: Satoshi
anchor_output_value = Word64 -> Satoshi
Satoshi Word64
330