module Data.Bitcoin.PaymentChannel.Internal.Types where
import Data.Bitcoin.PaymentChannel.Internal.Util
import Data.Bitcoin.PaymentChannel.Internal.Version
import qualified Network.Haskoin.Transaction as HT
import qualified Network.Haskoin.Crypto as HC
import qualified Network.Haskoin.Script as HS
import qualified Data.ByteString as B
import Data.Word (Word32, Word64, Word8)
import qualified Data.Binary as Bin
import qualified Data.Binary.Put as BinPut
import qualified Data.Binary.Get as BinGet
dUST_LIMIT = 700 :: Word64
mIN_CHANNEL_SIZE = dUST_LIMIT * 2
pROTOCOL_VERSION = CVersion 2 0
newtype UnsignedPaymentTx = CUnsignedPaymentTx { unsignedTx :: HT.Tx } deriving Show
type FinalTx = HT.Tx
data PaymentChannelState = CPaymentChannelState {
pcsParameters :: ChannelParameters,
pcsFundingTxInfo :: FundingTxInfo,
pcsPaymentConfig :: PaymentTxConfig,
pcsValueLeft :: BitcoinAmount,
pcsPaymentSignature :: Maybe PaymentSignature
} deriving (Eq, Show)
data ChannelParameters = CChannelParameters {
cpSenderPubKey :: HC.PubKey,
cpReceiverPubKey :: HC.PubKey,
cpLockTime :: BitcoinLockTime
} deriving (Eq, Show)
data FundingTxInfo = CFundingTxInfo {
ftiHash :: HT.TxHash,
ftiOutIndex :: Word32,
ftiOutValue :: BitcoinAmount
} deriving (Eq, Show)
data PaymentTxConfig = CPaymentTxConfig {
ptcSenderChangeScript :: B.ByteString,
ptcReceiverChangeScript :: B.ByteString
} deriving (Eq, Show)
data Payment = CPayment {
cpChannelValueLeft :: BitcoinAmount,
cpSignature :: PaymentSignature
}
data PaymentSignature = CPaymentSignature {
psSig :: HC.Signature
,psSigHash :: HS.SigHash
} deriving (Eq, Show)
instance Show Payment where
show (CPayment val sig) =
"<Payment: valLeft=" ++ show val ++ ">"