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

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

module Lightning.Protocol.BOLT3.Types (
    -- * Points and keys
    PerCommitmentPoint(..)
  , RevocationBasepoint(..)
  , PaymentBasepoint(..)
  , DelayedPaymentBasepoint(..)
  , HtlcBasepoint(..)
  , Basepoints(..)
  , RevocationPubkey(..)
  , LocalDelayedPubkey(..)
  , LocalHtlcPubkey(..)
  , RemoteHtlcPubkey(..)
  , RemotePubkey(..)
  , FundingPubkey(..)
  , Seckey(..)
  , seckey
  , un_seckey

    -- * Per-commitment secrets
  , Seed(..)
  , seed
  , un_seed
  , SecretIndex(..)
  , secret_index
  , un_secret_index
  , commitment_secret_index

    -- * Channel parameters
  , CommitmentNumber(..)
  , commitment_number
  , un_commitment_number
  , next_commitment_number
  , ToSelfDelay(..)
  , CltvExpiry(..)
  , DustLimit(..)
  , FeeratePerKw(..)
  , Locktime(..)
  , Sequence(..)
  , CommitmentFormat(..)

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

    -- * Scripts
  , Script(..)

    -- * Dust thresholds
  , dust_p2pkh
  , dust_p2sh
  , dust_p2wpkh
  , dust_p2wsh
  , anchor_output_value

    -- * Internal
  , sat
  , internal_error
  ) where

import Control.DeepSeq (NFData(..))
import qualified Crypto.Curve.Secp256k1 as S
import qualified Data.ByteString as BS
import Data.Word (Word16, Word32, Word64)
import GHC.Generics (Generic)
import Lightning.Protocol.BOLT1 (Point, Satoshi, MilliSatoshi, PaymentHash)
import qualified Lightning.Protocol.BOLT1 as BOLT1

-- internal ------------------------------------------------------------------

-- Abort on a state that the surrounding code rules out.
internal_error :: a
internal_error :: forall a. a
internal_error = [Char] -> a
forall a. HasCallStack => [Char] -> a
error [Char]
"ppad-bolt3: internal error, please report a bug!"
{-# NOINLINE internal_error #-}

-- A 'Satoshi' amount known to be at most 21 million BTC (a constant,
-- or a value bounded by construction).
sat :: Word64 -> Satoshi
sat :: Word64 -> Satoshi
sat Word64
w = case Word64 -> Maybe Satoshi
BOLT1.satoshi Word64
w of
  Just Satoshi
s  -> Satoshi
s
  Maybe Satoshi
Nothing -> Satoshi
forall a. a
internal_error
{-# INLINE sat #-}

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

-- | A per-commitment point, from which a commitment's keys are
--   derived.
newtype PerCommitmentPoint = PerCommitmentPoint 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 -> [Char]
(Int -> PerCommitmentPoint -> ShowS)
-> (PerCommitmentPoint -> [Char])
-> ([PerCommitmentPoint] -> ShowS)
-> Show PerCommitmentPoint
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerCommitmentPoint -> ShowS
showsPrec :: Int -> PerCommitmentPoint -> ShowS
$cshow :: PerCommitmentPoint -> [Char]
show :: PerCommitmentPoint -> [Char]
$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)

instance NFData PerCommitmentPoint

-- | A @revocation_basepoint@.
newtype RevocationBasepoint = RevocationBasepoint 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 -> [Char]
(Int -> RevocationBasepoint -> ShowS)
-> (RevocationBasepoint -> [Char])
-> ([RevocationBasepoint] -> ShowS)
-> Show RevocationBasepoint
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RevocationBasepoint -> ShowS
showsPrec :: Int -> RevocationBasepoint -> ShowS
$cshow :: RevocationBasepoint -> [Char]
show :: RevocationBasepoint -> [Char]
$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)

instance NFData RevocationBasepoint

-- | A @payment_basepoint@.
newtype PaymentBasepoint = PaymentBasepoint 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 -> [Char]
(Int -> PaymentBasepoint -> ShowS)
-> (PaymentBasepoint -> [Char])
-> ([PaymentBasepoint] -> ShowS)
-> Show PaymentBasepoint
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaymentBasepoint -> ShowS
showsPrec :: Int -> PaymentBasepoint -> ShowS
$cshow :: PaymentBasepoint -> [Char]
show :: PaymentBasepoint -> [Char]
$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)

instance NFData PaymentBasepoint

-- | A @delayed_payment_basepoint@.
newtype DelayedPaymentBasepoint = DelayedPaymentBasepoint 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 -> [Char]
(Int -> DelayedPaymentBasepoint -> ShowS)
-> (DelayedPaymentBasepoint -> [Char])
-> ([DelayedPaymentBasepoint] -> ShowS)
-> Show DelayedPaymentBasepoint
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DelayedPaymentBasepoint -> ShowS
showsPrec :: Int -> DelayedPaymentBasepoint -> ShowS
$cshow :: DelayedPaymentBasepoint -> [Char]
show :: DelayedPaymentBasepoint -> [Char]
$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)

instance NFData DelayedPaymentBasepoint

-- | An @htlc_basepoint@.
newtype HtlcBasepoint = HtlcBasepoint 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 -> [Char]
(Int -> HtlcBasepoint -> ShowS)
-> (HtlcBasepoint -> [Char])
-> ([HtlcBasepoint] -> ShowS)
-> Show HtlcBasepoint
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HtlcBasepoint -> ShowS
showsPrec :: Int -> HtlcBasepoint -> ShowS
$cshow :: HtlcBasepoint -> [Char]
show :: HtlcBasepoint -> [Char]
$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)

instance NFData HtlcBasepoint

-- | The four basepoints a party announces in @open_channel@ or
--   @accept_channel@.
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 -> [Char]
(Int -> Basepoints -> ShowS)
-> (Basepoints -> [Char])
-> ([Basepoints] -> ShowS)
-> Show Basepoints
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Basepoints -> ShowS
showsPrec :: Int -> Basepoints -> ShowS
$cshow :: Basepoints -> [Char]
show :: Basepoints -> [Char]
$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)

instance NFData Basepoints

-- | A commitment's @revocationpubkey@.
newtype RevocationPubkey = RevocationPubkey Point
  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 -> [Char]
(Int -> RevocationPubkey -> ShowS)
-> (RevocationPubkey -> [Char])
-> ([RevocationPubkey] -> ShowS)
-> Show RevocationPubkey
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RevocationPubkey -> ShowS
showsPrec :: Int -> RevocationPubkey -> ShowS
$cshow :: RevocationPubkey -> [Char]
show :: RevocationPubkey -> [Char]
$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)

instance NFData RevocationPubkey

-- | A commitment's @local_delayedpubkey@: the owner's key for its
--   delayed outputs.
newtype LocalDelayedPubkey = LocalDelayedPubkey Point
  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 -> [Char]
(Int -> LocalDelayedPubkey -> ShowS)
-> (LocalDelayedPubkey -> [Char])
-> ([LocalDelayedPubkey] -> ShowS)
-> Show LocalDelayedPubkey
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocalDelayedPubkey -> ShowS
showsPrec :: Int -> LocalDelayedPubkey -> ShowS
$cshow :: LocalDelayedPubkey -> [Char]
show :: LocalDelayedPubkey -> [Char]
$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)

instance NFData LocalDelayedPubkey

-- | A commitment's @local_htlcpubkey@: the owner's HTLC key.
newtype LocalHtlcPubkey = LocalHtlcPubkey Point
  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 -> [Char]
(Int -> LocalHtlcPubkey -> ShowS)
-> (LocalHtlcPubkey -> [Char])
-> ([LocalHtlcPubkey] -> ShowS)
-> Show LocalHtlcPubkey
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocalHtlcPubkey -> ShowS
showsPrec :: Int -> LocalHtlcPubkey -> ShowS
$cshow :: LocalHtlcPubkey -> [Char]
show :: LocalHtlcPubkey -> [Char]
$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)

instance NFData LocalHtlcPubkey

-- | A commitment's @remote_htlcpubkey@: the other party's HTLC key.
newtype RemoteHtlcPubkey = RemoteHtlcPubkey Point
  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 -> [Char]
(Int -> RemoteHtlcPubkey -> ShowS)
-> (RemoteHtlcPubkey -> [Char])
-> ([RemoteHtlcPubkey] -> ShowS)
-> Show RemoteHtlcPubkey
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoteHtlcPubkey -> ShowS
showsPrec :: Int -> RemoteHtlcPubkey -> ShowS
$cshow :: RemoteHtlcPubkey -> [Char]
show :: RemoteHtlcPubkey -> [Char]
$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)

instance NFData RemoteHtlcPubkey

-- | A commitment's @remotepubkey@: the other party's
--   @payment_basepoint@, which its @to_remote@ output pays.
newtype RemotePubkey = RemotePubkey Point
  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 -> [Char]
(Int -> RemotePubkey -> ShowS)
-> (RemotePubkey -> [Char])
-> ([RemotePubkey] -> ShowS)
-> Show RemotePubkey
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemotePubkey -> ShowS
showsPrec :: Int -> RemotePubkey -> ShowS
$cshow :: RemotePubkey -> [Char]
show :: RemotePubkey -> [Char]
$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)

instance NFData RemotePubkey

-- | A @funding_pubkey@.
newtype FundingPubkey = FundingPubkey Point
  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 -> [Char]
(Int -> FundingPubkey -> ShowS)
-> (FundingPubkey -> [Char])
-> ([FundingPubkey] -> ShowS)
-> Show FundingPubkey
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FundingPubkey -> ShowS
showsPrec :: Int -> FundingPubkey -> ShowS
$cshow :: FundingPubkey -> [Char]
show :: FundingPubkey -> [Char]
$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)

instance NFData FundingPubkey

-- | A secp256k1 secret key: 32 bytes encoding an integer in
--   [1, n), for n the group order.
--
--   This is secret material: its 'Show' instance is redacted, and it
--   has no 'Eq' instance.
newtype Seckey = Seckey BS.ByteString

instance Show Seckey where
  showsPrec :: Int -> Seckey -> ShowS
showsPrec Int
d Seckey
_ = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ [Char] -> ShowS
showString [Char]
"Seckey <redacted>"

instance NFData Seckey where
  rnf :: Seckey -> ()
rnf (Seckey ByteString
bs) = ByteString -> ()
forall a. NFData a => a -> ()
rnf ByteString
bs

-- | Construct a 'Seckey' from 32 big-endian bytes. Fails unless the
--   bytes encode an integer in [1, n).
--
--   >>> fmap (BS.length . un_seckey) (seckey (BS.replicate 32 0x01))
--   Just 32
--   >>> seckey (BS.replicate 32 0x00)
--   Nothing
--   >>> seckey (BS.replicate 32 0xff)
--   Nothing
seckey :: BS.ByteString -> Maybe Seckey
seckey :: ByteString -> Maybe Seckey
seckey ByteString
bs = do
  w <- ByteString -> Maybe Wider
S.parse_int256 ByteString
bs
  if   S.ge w
  then Just (Seckey bs)
  else Nothing

-- | The bytes of a 'Seckey'.
un_seckey :: Seckey -> BS.ByteString
un_seckey :: Seckey -> ByteString
un_seckey (Seckey ByteString
bs) = ByteString
bs
{-# INLINE un_seckey #-}

-- per-commitment secrets -----------------------------------------------------

-- | The 32-byte seed from which a party generates its per-commitment
--   secrets.
--
--   This is secret material: its 'Show' instance is redacted, and it
--   has no 'Eq' instance.
newtype Seed = Seed BS.ByteString

instance Show Seed where
  showsPrec :: Int -> Seed -> ShowS
showsPrec Int
d Seed
_ = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ [Char] -> ShowS
showString [Char]
"Seed <redacted>"

instance NFData Seed where
  rnf :: Seed -> ()
rnf (Seed ByteString
bs) = ByteString -> ()
forall a. NFData a => a -> ()
rnf ByteString
bs

-- | Construct a 'Seed' from exactly 32 bytes.
--
--   >>> fmap (BS.length . un_seed) (seed (BS.replicate 32 0xff))
--   Just 32
--   >>> seed (BS.replicate 31 0xff)
--   Nothing
seed :: BS.ByteString -> Maybe Seed
seed :: ByteString -> Maybe Seed
seed ByteString
bs
  | ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
32 = Seed -> Maybe Seed
forall a. a -> Maybe a
Just (ByteString -> Seed
Seed ByteString
bs)
  | Bool
otherwise          = Maybe Seed
forall a. Maybe a
Nothing
{-# INLINE seed #-}

-- | The bytes of a 'Seed'.
un_seed :: Seed -> BS.ByteString
un_seed :: Seed -> ByteString
un_seed (Seed ByteString
bs) = ByteString
bs
{-# INLINE un_seed #-}

-- | The 48-bit index /I/ of a per-commitment secret. Secrets are
--   used from index 2^48 - 1 downwards.
newtype SecretIndex = SecretIndex Word64
  deriving (SecretIndex -> SecretIndex -> Bool
(SecretIndex -> SecretIndex -> Bool)
-> (SecretIndex -> SecretIndex -> Bool) -> Eq SecretIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SecretIndex -> SecretIndex -> Bool
== :: SecretIndex -> SecretIndex -> Bool
$c/= :: SecretIndex -> SecretIndex -> Bool
/= :: SecretIndex -> SecretIndex -> Bool
Eq, Eq SecretIndex
Eq SecretIndex =>
(SecretIndex -> SecretIndex -> Ordering)
-> (SecretIndex -> SecretIndex -> Bool)
-> (SecretIndex -> SecretIndex -> Bool)
-> (SecretIndex -> SecretIndex -> Bool)
-> (SecretIndex -> SecretIndex -> Bool)
-> (SecretIndex -> SecretIndex -> SecretIndex)
-> (SecretIndex -> SecretIndex -> SecretIndex)
-> Ord SecretIndex
SecretIndex -> SecretIndex -> Bool
SecretIndex -> SecretIndex -> Ordering
SecretIndex -> SecretIndex -> SecretIndex
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 :: SecretIndex -> SecretIndex -> Ordering
compare :: SecretIndex -> SecretIndex -> Ordering
$c< :: SecretIndex -> SecretIndex -> Bool
< :: SecretIndex -> SecretIndex -> Bool
$c<= :: SecretIndex -> SecretIndex -> Bool
<= :: SecretIndex -> SecretIndex -> Bool
$c> :: SecretIndex -> SecretIndex -> Bool
> :: SecretIndex -> SecretIndex -> Bool
$c>= :: SecretIndex -> SecretIndex -> Bool
>= :: SecretIndex -> SecretIndex -> Bool
$cmax :: SecretIndex -> SecretIndex -> SecretIndex
max :: SecretIndex -> SecretIndex -> SecretIndex
$cmin :: SecretIndex -> SecretIndex -> SecretIndex
min :: SecretIndex -> SecretIndex -> SecretIndex
Ord, Int -> SecretIndex -> ShowS
[SecretIndex] -> ShowS
SecretIndex -> [Char]
(Int -> SecretIndex -> ShowS)
-> (SecretIndex -> [Char])
-> ([SecretIndex] -> ShowS)
-> Show SecretIndex
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SecretIndex -> ShowS
showsPrec :: Int -> SecretIndex -> ShowS
$cshow :: SecretIndex -> [Char]
show :: SecretIndex -> [Char]
$cshowList :: [SecretIndex] -> ShowS
showList :: [SecretIndex] -> ShowS
Show, (forall x. SecretIndex -> Rep SecretIndex x)
-> (forall x. Rep SecretIndex x -> SecretIndex)
-> Generic SecretIndex
forall x. Rep SecretIndex x -> SecretIndex
forall x. SecretIndex -> Rep SecretIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SecretIndex -> Rep SecretIndex x
from :: forall x. SecretIndex -> Rep SecretIndex x
$cto :: forall x. Rep SecretIndex x -> SecretIndex
to :: forall x. Rep SecretIndex x -> SecretIndex
Generic)

instance NFData SecretIndex

-- | Construct a 'SecretIndex'. Fails at or above 2^48.
--
--   >>> secret_index 281474976710655
--   Just (SecretIndex 281474976710655)
--   >>> secret_index 281474976710656
--   Nothing
secret_index :: Word64 -> Maybe SecretIndex
secret_index :: Word64 -> Maybe SecretIndex
secret_index Word64
w
  | Word64
w Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
<= Word64
0xFFFFFFFFFFFF = SecretIndex -> Maybe SecretIndex
forall a. a -> Maybe a
Just (Word64 -> SecretIndex
SecretIndex Word64
w)
  | Bool
otherwise           = Maybe SecretIndex
forall a. Maybe a
Nothing
{-# INLINE secret_index #-}

-- | The value of a 'SecretIndex'.
un_secret_index :: SecretIndex -> Word64
un_secret_index :: SecretIndex -> Word64
un_secret_index (SecretIndex Word64
w) = Word64
w
{-# INLINE un_secret_index #-}

-- | The index of the per-commitment secret for a commitment number:
--   2^48 - 1 - n.
--
--   >>> fmap commitment_secret_index (commitment_number 0)
--   Just (SecretIndex 281474976710655)
commitment_secret_index :: CommitmentNumber -> SecretIndex
commitment_secret_index :: CommitmentNumber -> SecretIndex
commitment_secret_index (CommitmentNumber Word64
n) = Word64 -> SecretIndex
SecretIndex (Word64
0xFFFFFFFFFFFF Word64 -> Word64 -> Word64
forall a. Num a => a -> a -> a
- Word64
n)
{-# INLINE commitment_secret_index #-}

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

-- | A 48-bit commitment number.
newtype CommitmentNumber = CommitmentNumber 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 -> [Char]
(Int -> CommitmentNumber -> ShowS)
-> (CommitmentNumber -> [Char])
-> ([CommitmentNumber] -> ShowS)
-> Show CommitmentNumber
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommitmentNumber -> ShowS
showsPrec :: Int -> CommitmentNumber -> ShowS
$cshow :: CommitmentNumber -> [Char]
show :: CommitmentNumber -> [Char]
$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)

instance NFData CommitmentNumber

-- | Construct a 'CommitmentNumber'. Fails at or above 2^48.
--
--   >>> commitment_number 42
--   Just (CommitmentNumber 42)
--   >>> commitment_number 281474976710656
--   Nothing
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
0xFFFFFFFFFFFF = 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 #-}

-- | The value of a 'CommitmentNumber'.
un_commitment_number :: CommitmentNumber -> Word64
un_commitment_number :: CommitmentNumber -> Word64
un_commitment_number (CommitmentNumber Word64
n) = Word64
n
{-# INLINE un_commitment_number #-}

-- | The next commitment number. Fails past 2^48 - 1.
--
--   >>> commitment_number 0 >>= next_commitment_number
--   Just (CommitmentNumber 1)
--   >>> commitment_number 281474976710655 >>= next_commitment_number
--   Nothing
next_commitment_number :: CommitmentNumber -> Maybe CommitmentNumber
next_commitment_number :: CommitmentNumber -> Maybe CommitmentNumber
next_commitment_number (CommitmentNumber Word64
n)
  | Word64
n Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
< Word64
0xFFFFFFFFFFFF = CommitmentNumber -> Maybe CommitmentNumber
forall a. a -> Maybe a
Just (Word64 -> CommitmentNumber
CommitmentNumber (Word64
n Word64 -> Word64 -> Word64
forall a. Num a => a -> a -> a
+ Word64
1))
  | Bool
otherwise          = Maybe CommitmentNumber
forall a. Maybe a
Nothing
{-# INLINE next_commitment_number #-}

-- | The CSV delay (@to_self_delay@) on a commitment owner's outputs.
newtype ToSelfDelay = ToSelfDelay 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 -> [Char]
(Int -> ToSelfDelay -> ShowS)
-> (ToSelfDelay -> [Char])
-> ([ToSelfDelay] -> ShowS)
-> Show ToSelfDelay
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToSelfDelay -> ShowS
showsPrec :: Int -> ToSelfDelay -> ShowS
$cshow :: ToSelfDelay -> [Char]
show :: ToSelfDelay -> [Char]
$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)

instance NFData ToSelfDelay

-- | An HTLC's absolute CLTV expiry.
newtype CltvExpiry = CltvExpiry 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 -> [Char]
(Int -> CltvExpiry -> ShowS)
-> (CltvExpiry -> [Char])
-> ([CltvExpiry] -> ShowS)
-> Show CltvExpiry
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CltvExpiry -> ShowS
showsPrec :: Int -> CltvExpiry -> ShowS
$cshow :: CltvExpiry -> [Char]
show :: CltvExpiry -> [Char]
$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)

instance NFData CltvExpiry

-- | A @dust_limit_satoshis@ threshold.
newtype DustLimit = DustLimit 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 -> [Char]
(Int -> DustLimit -> ShowS)
-> (DustLimit -> [Char])
-> ([DustLimit] -> ShowS)
-> Show DustLimit
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DustLimit -> ShowS
showsPrec :: Int -> DustLimit -> ShowS
$cshow :: DustLimit -> [Char]
show :: DustLimit -> [Char]
$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)

instance NFData DustLimit

-- | A fee rate, in satoshis per 1000 weight units.
newtype FeeratePerKw = FeeratePerKw 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 -> [Char]
(Int -> FeeratePerKw -> ShowS)
-> (FeeratePerKw -> [Char])
-> ([FeeratePerKw] -> ShowS)
-> Show FeeratePerKw
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FeeratePerKw -> ShowS
showsPrec :: Int -> FeeratePerKw -> ShowS
$cshow :: FeeratePerKw -> [Char]
show :: FeeratePerKw -> [Char]
$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)

instance NFData FeeratePerKw

-- | A transaction locktime.
newtype Locktime = Locktime 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 -> [Char]
(Int -> Locktime -> ShowS)
-> (Locktime -> [Char]) -> ([Locktime] -> ShowS) -> Show Locktime
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Locktime -> ShowS
showsPrec :: Int -> Locktime -> ShowS
$cshow :: Locktime -> [Char]
show :: Locktime -> [Char]
$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)

instance NFData Locktime

-- | A transaction input's sequence number.
newtype Sequence = Sequence 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 -> [Char]
(Int -> Sequence -> ShowS)
-> (Sequence -> [Char]) -> ([Sequence] -> ShowS) -> Show Sequence
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Sequence -> ShowS
showsPrec :: Int -> Sequence -> ShowS
$cshow :: Sequence -> [Char]
show :: Sequence -> [Char]
$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)

instance NFData Sequence

-- | The commitment format a channel uses, as fixed by its
--   @channel_type@.
data CommitmentFormat
  = StaticRemotekey
    -- ^ @option_static_remotekey@ without anchors: @to_remote@ is
    --   P2WPKH and HTLC transactions pay their own fees.
  | Anchors
    -- ^ @option_anchors@: two anchor outputs, a CSV-locked
    --   @to_remote@, and zero-fee HTLC transactions.
  deriving (CommitmentFormat -> CommitmentFormat -> Bool
(CommitmentFormat -> CommitmentFormat -> Bool)
-> (CommitmentFormat -> CommitmentFormat -> Bool)
-> Eq CommitmentFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommitmentFormat -> CommitmentFormat -> Bool
== :: CommitmentFormat -> CommitmentFormat -> Bool
$c/= :: CommitmentFormat -> CommitmentFormat -> Bool
/= :: CommitmentFormat -> CommitmentFormat -> Bool
Eq, Eq CommitmentFormat
Eq CommitmentFormat =>
(CommitmentFormat -> CommitmentFormat -> Ordering)
-> (CommitmentFormat -> CommitmentFormat -> Bool)
-> (CommitmentFormat -> CommitmentFormat -> Bool)
-> (CommitmentFormat -> CommitmentFormat -> Bool)
-> (CommitmentFormat -> CommitmentFormat -> Bool)
-> (CommitmentFormat -> CommitmentFormat -> CommitmentFormat)
-> (CommitmentFormat -> CommitmentFormat -> CommitmentFormat)
-> Ord CommitmentFormat
CommitmentFormat -> CommitmentFormat -> Bool
CommitmentFormat -> CommitmentFormat -> Ordering
CommitmentFormat -> CommitmentFormat -> CommitmentFormat
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 :: CommitmentFormat -> CommitmentFormat -> Ordering
compare :: CommitmentFormat -> CommitmentFormat -> Ordering
$c< :: CommitmentFormat -> CommitmentFormat -> Bool
< :: CommitmentFormat -> CommitmentFormat -> Bool
$c<= :: CommitmentFormat -> CommitmentFormat -> Bool
<= :: CommitmentFormat -> CommitmentFormat -> Bool
$c> :: CommitmentFormat -> CommitmentFormat -> Bool
> :: CommitmentFormat -> CommitmentFormat -> Bool
$c>= :: CommitmentFormat -> CommitmentFormat -> Bool
>= :: CommitmentFormat -> CommitmentFormat -> Bool
$cmax :: CommitmentFormat -> CommitmentFormat -> CommitmentFormat
max :: CommitmentFormat -> CommitmentFormat -> CommitmentFormat
$cmin :: CommitmentFormat -> CommitmentFormat -> CommitmentFormat
min :: CommitmentFormat -> CommitmentFormat -> CommitmentFormat
Ord, Int -> CommitmentFormat -> ShowS
[CommitmentFormat] -> ShowS
CommitmentFormat -> [Char]
(Int -> CommitmentFormat -> ShowS)
-> (CommitmentFormat -> [Char])
-> ([CommitmentFormat] -> ShowS)
-> Show CommitmentFormat
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommitmentFormat -> ShowS
showsPrec :: Int -> CommitmentFormat -> ShowS
$cshow :: CommitmentFormat -> [Char]
show :: CommitmentFormat -> [Char]
$cshowList :: [CommitmentFormat] -> ShowS
showList :: [CommitmentFormat] -> ShowS
Show, (forall x. CommitmentFormat -> Rep CommitmentFormat x)
-> (forall x. Rep CommitmentFormat x -> CommitmentFormat)
-> Generic CommitmentFormat
forall x. Rep CommitmentFormat x -> CommitmentFormat
forall x. CommitmentFormat -> Rep CommitmentFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CommitmentFormat -> Rep CommitmentFormat x
from :: forall x. CommitmentFormat -> Rep CommitmentFormat x
$cto :: forall x. Rep CommitmentFormat x -> CommitmentFormat
to :: forall x. Rep CommitmentFormat x -> CommitmentFormat
Generic)

instance NFData CommitmentFormat

-- HTLCs ----------------------------------------------------------------------

-- | The direction of an HTLC, from the commitment owner's point of
--   view.
data HTLCDirection
  = HTLCOffered   -- ^ offered by the owner
  | HTLCReceived  -- ^ received by the owner
  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 -> [Char]
(Int -> HTLCDirection -> ShowS)
-> (HTLCDirection -> [Char])
-> ([HTLCDirection] -> ShowS)
-> Show HTLCDirection
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HTLCDirection -> ShowS
showsPrec :: Int -> HTLCDirection -> ShowS
$cshow :: HTLCDirection -> [Char]
show :: HTLCDirection -> [Char]
$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)

instance NFData HTLCDirection

-- | An HTLC committed to a commitment transaction.
data HTLC = HTLC
  { HTLC -> HTLCDirection
htlc_direction    :: !HTLCDirection
  , HTLC -> MilliSatoshi
htlc_amount_msat  :: {-# UNPACK #-} !MilliSatoshi
  , HTLC -> PaymentHash
htlc_payment_hash :: !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 -> [Char]
(Int -> HTLC -> ShowS)
-> (HTLC -> [Char]) -> ([HTLC] -> ShowS) -> Show HTLC
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HTLC -> ShowS
showsPrec :: Int -> HTLC -> ShowS
$cshow :: HTLC -> [Char]
show :: HTLC -> [Char]
$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)

instance NFData HTLC

-- scripts --------------------------------------------------------------------

-- | A serialized Bitcoin script.
newtype Script = Script 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 -> [Char]
(Int -> Script -> ShowS)
-> (Script -> [Char]) -> ([Script] -> ShowS) -> Show Script
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Script -> ShowS
showsPrec :: Int -> Script -> ShowS
$cshow :: Script -> [Char]
show :: Script -> [Char]
$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)

instance NFData Script

-- dust thresholds ------------------------------------------------------------

-- | Bitcoin Core's P2PKH dust threshold (546 satoshis).
dust_p2pkh :: Satoshi
dust_p2pkh :: Satoshi
dust_p2pkh = Word64 -> Satoshi
sat Word64
546

-- | Bitcoin Core's P2SH dust threshold (540 satoshis).
dust_p2sh :: Satoshi
dust_p2sh :: Satoshi
dust_p2sh = Word64 -> Satoshi
sat Word64
540

-- | Bitcoin Core's P2WPKH dust threshold (294 satoshis).
dust_p2wpkh :: Satoshi
dust_p2wpkh :: Satoshi
dust_p2wpkh = Word64 -> Satoshi
sat Word64
294

-- | Bitcoin Core's P2WSH dust threshold (330 satoshis).
dust_p2wsh :: Satoshi
dust_p2wsh :: Satoshi
dust_p2wsh = Word64 -> Satoshi
sat Word64
330

-- | The value of each anchor output (330 satoshis).
anchor_output_value :: Satoshi
anchor_output_value :: Satoshi
anchor_output_value = Word64 -> Satoshi
sat Word64
330