module Data.Bitcoin.PaymentChannel.Util
(
getFundingAddress,getRedeemScript,
setSenderChangeAddress,
serialize, deserEither,
BitcoinLockTime, parseBitcoinLocktime, toWord32, fromDate,
parseJSONInt,
pGetSig,fpGetSig,
unsafeUpdateRecvState
)
where
import Data.Bitcoin.PaymentChannel.Internal.Types
(PaymentChannelState(..),
Payment(..), PaymentSignature(..))
import Data.Bitcoin.PaymentChannel.Internal.Bitcoin.Script
(getP2SHFundingAddress, getRedeemScript)
import Data.Bitcoin.PaymentChannel.Internal.Util
(parseBitcoinLocktime, toWord32, deserEither, serialize)
import Data.Bitcoin.PaymentChannel.Internal.State
(setClientChangeAddress)
import Data.Bitcoin.PaymentChannel.Internal.Serialization
(parseJSONInt)
import Data.Bitcoin.PaymentChannel.Types
import qualified Network.Haskoin.Crypto as HC
getFundingAddress :: ChannelParameters -> HC.Address
getFundingAddress = getP2SHFundingAddress
setSenderChangeAddress :: PaymentChannel a => a -> HC.Address -> a
setSenderChangeAddress pch addr =
_setChannelState pch (setClientChangeAddress (getChannelState pch) addr)
unsafeUpdateRecvState :: ReceiverPaymentChannel -> Payment -> ReceiverPaymentChannel
unsafeUpdateRecvState (CReceiverPaymentChannel s) (CPayment val sig) =
CReceiverPaymentChannel $ s { pcsClientChangeVal = val, pcsPaymentSignature = sig}
fpGetSig :: FullPayment -> HC.Signature
fpGetSig = psSig . cpSignature . fpPayment
pGetSig :: Payment -> HC.Signature
pGetSig = psSig . cpSignature