bitcoin-script 0.11.0 → 0.11.1
raw patch · 3 files changed
+14/−5 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Bitcoin.Script: OP_INVALIDOPCODE :: !Word8 -> ScriptOp
+ Data.Bitcoin.Script: OP_INVALIDOPCODE :: Word8 -> ScriptOp
- Data.Bitcoin.Script: OP_PUSHDATA :: !ByteString -> !PushDataType -> ScriptOp
+ Data.Bitcoin.Script: OP_PUSHDATA :: ByteString -> PushDataType -> ScriptOp
- Data.Bitcoin.Script: Script :: ![ScriptOp] -> Script
+ Data.Bitcoin.Script: Script :: [ScriptOp] -> Script
- Data.Bitcoin.Script: scriptOps :: Script -> ![ScriptOp]
+ Data.Bitcoin.Script: scriptOps :: Script -> [ScriptOp]
Files
- bitcoin-script.cabal +1/−1
- src/Data/Bitcoin/Script/Types.hs +3/−3
- test/Data/Bitcoin/ScriptSpec.hs +10/−1
bitcoin-script.cabal view
@@ -1,6 +1,6 @@ name: bitcoin-script category: Network, Finance -version: 0.11.0 +version: 0.11.1 license: MIT license-file: LICENSE copyright: (c) 2015 Leon Mergen
src/Data/Bitcoin/Script/Types.hs view
@@ -38,7 +38,7 @@ data Script = Script { -- | List of script operators defining this script - scriptOps :: ![ScriptOp] + scriptOps :: [ScriptOp] } deriving (Eq, Show, Read) @@ -73,7 +73,7 @@ -- | Data type representing all of the operators allowed inside a 'Script'. data ScriptOp -- Pushing Data - = OP_PUSHDATA !BS.ByteString !PushDataType + = OP_PUSHDATA BS.ByteString PushDataType | OP_0 | OP_1NEGATE | OP_RESERVED @@ -181,7 +181,7 @@ -- Other | OP_PUBKEYHASH | OP_PUBKEY - | OP_INVALIDOPCODE !Word8 + | OP_INVALIDOPCODE Word8 deriving (Show, Read, Eq)
test/Data/Bitcoin/ScriptSpec.hs view
@@ -1,7 +1,10 @@+{-# LANGUAGE TemplateHaskell #-} + module Data.Bitcoin.ScriptSpec where import Data.Bitcoin.Script +import qualified Data.ByteString.Char8 as BS8 (pack) import qualified Data.ByteString.Lazy.Char8 as BSL8 (pack) import Test.Hspec @@ -14,10 +17,16 @@ (encode . decode) hex `shouldBe` hex - it "succesfully parses a transaction into a meaningful object" $ do + it "succesfully parses a script into a meaningful object" $ do let hex = BSL8.pack "76a914975efcba1e058667594dc57146022ec46560a63c88ac" decoded = decode hex case decoded of (Script [OP_DUP, OP_HASH160, OP_PUSHDATA _ OPCODE, OP_EQUALVERIFY, OP_CHECKSIG]) -> return () _ -> expectationFailure ("Result does not match expected: " ++ show decoded) + + it "succesfully parses an OP_RETURN script into a meaningful object" $ do + let hex = BSL8.pack "6a0b68656c6c6f20776f726c64" + decoded = decode hex + + decoded `shouldBe` (Script [OP_RETURN, OP_PUSHDATA (BS8.pack "hello world") OPCODE])