bitcoin-payment-channel 0.2.2.0 → 0.2.3.0
raw patch · 4 files changed
+22/−18 lines, 4 filesdep ~aesondep ~base16-bytestringdep ~base58string
Dependency ranges changed: aeson, base16-bytestring, base58string, base64-bytestring, binary, bytestring, cereal, errors, haskoin-core, hexstring, scientific, text, time
Files
- bitcoin-payment-channel.cabal +17/−9
- src/Data/Bitcoin/PaymentChannel/Internal/BitcoinAmount.hs +3/−2
- src/Data/Bitcoin/PaymentChannel/Internal/Types.hs +1/−1
- test/Main.hs +1/−6
bitcoin-payment-channel.cabal view
@@ -1,5 +1,5 @@ name: bitcoin-payment-channel-version: 0.2.2.0+version: 0.2.3.0 synopsis: Library for working with Bitcoin payment channels description: A Bitcoin payment channel allows secure and instant transfer of bitcoins from one@@ -40,9 +40,9 @@ Data.Bitcoin.PaymentChannel.Internal.BitcoinAmount, Data.Bitcoin.PaymentChannel.Internal.Payment, Data.Bitcoin.PaymentChannel.Internal.Refund,+ Data.Bitcoin.PaymentChannel.Internal.State, Data.Bitcoin.PaymentChannel.Internal.Script, Data.Bitcoin.PaymentChannel.Internal.Settlement,- Data.Bitcoin.PaymentChannel.Internal.State, Data.Bitcoin.PaymentChannel.Internal.Types, Data.Bitcoin.PaymentChannel.Internal.Serialization, Data.Bitcoin.PaymentChannel.Internal.Util,@@ -51,13 +51,21 @@ ghc-options: -W - build-depends: base >= 4.7 && < 5,- haskoin-core >= 0.3.1 && < 1.0.0,- bytestring, text, base16-bytestring, base58string, hexstring,- base64-bytestring,- time,- errors,- cereal, binary, aeson, scientific+ build-depends: base >= 4.7 && < 5,+ haskoin-core >= 0.3.1 && < 0.4.0,+ base16-bytestring >= 0.1.0 && < 0.2.0,+ base58string >= 0.10.0 && < 0.11.0,+ base64-bytestring >= 1.0.0 && < 1.1.0,+ binary >= 0.7.0 && < 0.8.0,+ bytestring >= 0.10.0 && < 0.11.0,+ cereal >= 0.5.0 && < 0.6.0,+ errors >= 2.0.0 && < 2.2.0,+ hexstring >= 0.11.0 && < 0.12.0,+ text >= 1.2.0 && < 1.3.0,+ time >= 1.5.0 && < 1.6.0,+ aeson >= 0.11.0 && < 0.12.0,+ scientific >= 0.3.0 && < 0.4.0+ hs-source-dirs: src default-language: Haskell2010
src/Data/Bitcoin/PaymentChannel/Internal/BitcoinAmount.hs view
@@ -23,7 +23,7 @@ instance Num BitcoinAmount where -- We leave multiplication of two money amounts as undefined- (BitcoinAmount _) * (BitcoinAmount _) = undefined+ (BitcoinAmount a1) * (BitcoinAmount a2) = BitcoinAmount (fromIntegral . capToWord64 $ a1*a2) (BitcoinAmount a1) + (BitcoinAmount a2) = BitcoinAmount (fromIntegral . capToWord64 $ a1+a2) (BitcoinAmount a1) - (BitcoinAmount a2) = BitcoinAmount (fromIntegral . capToWord64 $ a1-a2) abs = id -- Always positive@@ -41,7 +41,8 @@ instance Integral BitcoinAmount where toInteger (BitcoinAmount int) = int -- Dividing one money amounts by another doesn't make sense either- quotRem (BitcoinAmount _) (BitcoinAmount _) = undefined+ quotRem (BitcoinAmount _) (BitcoinAmount _) =+ error "Division of two BitcoinAmounts is undefined" -- | Convert to 'Word64', with zero as floor, (maxBound :: Word64) as ceiling capToWord64 :: Integer -> Word64
src/Data/Bitcoin/PaymentChannel/Internal/Types.hs view
@@ -20,7 +20,7 @@ dUST_LIMIT = 700 :: BitcoinAmount-mIN_CHANNEL_SIZE = dUST_LIMIT * 2+mIN_CHANNEL_SIZE = 1400 :: BitcoinAmount pROTOCOL_VERSION = CVersion 2 0 newtype UnsignedPaymentTx = CUnsignedPaymentTx { unsignedTx :: HT.Tx } deriving Show
test/Main.hs view
@@ -80,11 +80,7 @@ checkChanPair :: ArbChannelPair -> Bool checkChanPair (ArbChannelPair sendChan recvChan) =- ("valLeft: " ++ show (valueToMe sendChan)) `trace`- getChannelState recvChan == getChannelState sendChan--- case getSettlementBitcoinTx sendChan 0 of--- Left e -> False--- Right tx -> True+ getChannelState recvChan == getChannelState sendChan testChanPair :: ArbChannelPair -> [BitcoinAmount] -> Bool testChanPair p al = checkChanPair (runChanPair p al)@@ -94,7 +90,6 @@ quickCheckWith stdArgs -- { maxSuccess = 25 } testChanPair -- (verbose $ testChanPair)-