module Data.Bitcoin.PaymentChannel.Internal.Types
(
module Data.Bitcoin.PaymentChannel.Internal.Types
, module Data.Bitcoin.PaymentChannel.Internal.Bitcoin.Amount
, module Data.Bitcoin.PaymentChannel.Internal.Bitcoin.LockTime
, module Network.Haskoin.Transaction
, module Network.Haskoin.Crypto
, module Network.Haskoin.Script
)
where
import Data.Bitcoin.PaymentChannel.Internal.Util
import Data.Bitcoin.PaymentChannel.Internal.Bitcoin.Amount
import Data.Bitcoin.PaymentChannel.Internal.Bitcoin.LockTime
import Network.Haskoin.Transaction
import Network.Haskoin.Crypto
import Network.Haskoin.Script
import qualified Network.Haskoin.Transaction as HT
import qualified Network.Haskoin.Crypto as HC
import qualified Network.Haskoin.Script as HS
import Data.Typeable
import Data.Word
import GHC.Generics
defaultDustLimit = 700 :: BitcoinAmount
defaultMinChanSize = defaultDustLimit * 2
newtype UnsignedPaymentTx = CUnsignedPaymentTx { unsignedTx :: HT.Tx } deriving Show
type FinalTx = HT.Tx
data PaymentChannelState = CPaymentChannelState {
pcsParameters :: ChannelParameters,
pcsFundingTxInfo :: FundingTxInfo,
pcsPaymentConfig :: PaymentTxConfig,
pcsClientChangeVal :: BitcoinAmount,
pcsPaymentSignature :: PaymentSignature
} deriving (Eq, Show, Typeable)
data ChannelParameters = CChannelParameters {
cpSenderPubKey :: SendPubKey,
cpReceiverPubKey :: RecvPubKey,
cpLockTime :: BitcoinLockTime,
cpDustLimit :: BitcoinAmount
} deriving (Eq, Show, Typeable)
data FundingTxInfo = CFundingTxInfo {
ftiHash :: HT.TxHash,
ftiOutIndex :: Word32,
ftiOutValue :: BitcoinAmount
} deriving (Eq, Show, Typeable)
data PaymentTxConfig = CPaymentTxConfig {
ptcSenderChangeAddress :: HC.Address
} deriving (Eq, Show, Typeable)
data Payment = CPayment {
cpClientChange :: BitcoinAmount
, cpSignature :: PaymentSignature
} deriving (Eq, Typeable)
data FullPayment = CFullPayment {
fpPayment :: Payment
, fpOutPoint :: HT.OutPoint
, fpRedeemScript :: HS.Script
, fpChangeAddr :: HC.Address
} deriving (Eq, Typeable)
data PaymentSignature = CPaymentSignature {
psSig :: HC.Signature
,psSigHash :: HS.SigHash
} deriving (Eq, Show, Typeable)
newtype ChanScript = ChanScript { getScript :: HS.Script } deriving (Eq, Show)
newtype SendPubKey = MkSendPubKey {
getSenderPK :: HC.PubKey
} deriving (Eq, Show)
newtype RecvPubKey = MkRecvPubKey {
getReceiverPK :: HC.PubKey
} deriving (Eq, Show)
class IsPubKey a where
getPubKey :: a -> HC.PubKey
instance IsPubKey SendPubKey where
getPubKey = getSenderPK
instance IsPubKey RecvPubKey where
getPubKey = getReceiverPK