module Data.Bitcoin.PaymentChannel.Internal.Bitcoin.Fee where
import Data.Bitcoin.PaymentChannel.Internal.Bitcoin.Amount
import qualified Data.Serialize as Bin
class HasFee a where
absoluteFee :: TxByteSize -> a -> BitcoinAmount
instance HasFee BitcoinAmount where
absoluteFee _ = id
data Constant = Constant BitcoinAmount
instance HasFee Constant where
absoluteFee _ (Constant amt) = amt
type TxByteSize = Word
newtype SatoshisPerByte = SatoshisPerByte BitcoinAmount
deriving (Eq, Show, Bin.Serialize, Ord, Num, Enum, Real, Integral)
instance HasFee SatoshisPerByte where
absoluteFee txByteSize (SatoshisPerByte satoshisPerByte) =
fromIntegral txByteSize * satoshisPerByte