{-# LANGUAGE RecordWildCards, FlexibleContexts #-}
module PaymentChannel.Internal.Settlement
where
import PaymentChannel.Internal.Settlement.Util
import PaymentChannel.Internal.Receiver.Util
import PaymentChannel.Internal.Error.Internal
type SignedTx = BtcTx P2SH ChanParams PaymentScriptSig
getSignedSettlementTx :: forall signKey coi kd.
DeriveChangeOut SignedPayment coi signKey ChanParams
=> ServerPayChanI kd
-> coi
-> SignM signKey (Either ReceiverError SignedTx)
getSignedSettlementTx rpc chgOut =
fmapL SettleSigningError <$> signChangeTx (pcsPayment . rpcState $ rpc) chgOut