{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module PaymentChannel.Internal.Crypto.PubKey
( IsPubKey(..)
, SendPubKey(..)
, RecvPubKey(..)
, HasSendPubKey(..)
, HasRecvPubKey(..)
) where
import Data.Word (Word32)
import qualified Network.Haskoin.Crypto as HC
import PaymentChannel.Internal.Util
class Serialize a => IsPubKey a where
getPubKey :: a -> HC.PubKeyC
instance IsPubKey HC.PubKeyC where
getPubKey = id
newtype SendPubKey = MkSendPubKey {
getSenderPK :: HC.PubKeyC
} deriving (Eq, Show, Serialize, Generic, FromJSON, ToJSON, NFData)
instance IsPubKey SendPubKey where
getPubKey = getSenderPK
newtype RecvPubKey = MkRecvPubKey {
getReceiverPK :: HC.PubKeyC
} deriving (Eq, Show, Serialize, Generic, FromJSON, ToJSON, NFData)
instance IsPubKey RecvPubKey where
getPubKey = getReceiverPK
instance IsPubKey HC.XPubKey where
getPubKey = HC.xPubKey
class HasSendPubKey a where
getSendPubKey :: a -> SendPubKey
class HasRecvPubKey a where
getRecvPubKey :: a -> RecvPubKey