From 235038ae40f94279910b0dce1a6f0e21fb6fd0a7 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Rupp Date: Thu, 14 May 2020 19:35:04 +0100 Subject: [PATCH] Support for Bitcoin Cash May 2020 hard fork --- .gitignore | 1 - CHANGELOG.md | 4 + haskoin-core.cabal | 200 +++++++++++++++++++++++++++++++++++ package.yaml | 2 +- src/Haskoin/Script/Common.hs | 8 ++ test/Haskoin/ScriptSpec.hs | 1 - test/Haskoin/Test/Script.hs | 5 + 7 files changed, 218 insertions(+), 3 deletions(-) create mode 100644 haskoin-core.cabal diff --git a/.gitignore b/.gitignore index f2fdd856..fb6f9d11 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,5 @@ cabal.project.local cabal.project.local~ .HTF/ .ghc.environment.* -haskoin-core.cabal TAGS tags diff --git a/CHANGELOG.md b/CHANGELOG.md index 74fd0637..723d8f30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.13.4 +### Added +- Support for Bitcoin Cash May 2020 hard fork. + ## 0.13.3 ### Changed - Improve code and documentation organisation. diff --git a/haskoin-core.cabal b/haskoin-core.cabal new file mode 100644 index 00000000..c952cb72 --- /dev/null +++ b/haskoin-core.cabal @@ -0,0 +1,200 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.33.0. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: ee5ff7456453fe4afdfd49adb164df9da4ea7368e9f8a04d4d4315b2d29a14ab + +name: haskoin-core +version: 0.13.4 +synopsis: Bitcoin & Bitcoin Cash library for Haskell +description: Haskoin Core is a complete Bitcoin and Bitcoin Cash library of functions and data types for Haskell developers. +category: Bitcoin, Finance, Network +homepage: http://github.com/haskoin/haskoin#readme +bug-reports: http://github.com/haskoin/haskoin/issues +author: Philippe Laprade, + Jean-Pierre Rupp, + Matthew Wraith +maintainer: jprupp@protonmail.ch +license: PublicDomain +license-file: UNLICENSE +build-type: Simple +extra-source-files: + data/forkid_script_tests.json + data/forkid_sighash.json + data/script_tests.json + data/sig_nonstrict.json + data/sig_strict.json + data/sighash.json + README.md + CHANGELOG.md + +source-repository head + type: git + location: git://github.com/haskoin/haskoin.git + +library + exposed-modules: + Haskoin + Haskoin.Address + Haskoin.Block + Haskoin.Constants + Haskoin.Crypto + Haskoin.Keys + Haskoin.Network + Haskoin.Script + Haskoin.Transaction + Haskoin.Util + other-modules: + Haskoin.Address.Base58 + Haskoin.Address.Bech32 + Haskoin.Address.CashAddr + Haskoin.Block.Common + Haskoin.Block.Headers + Haskoin.Block.Merkle + Haskoin.Crypto.Hash + Haskoin.Crypto.Signature + Haskoin.Keys.Common + Haskoin.Keys.Extended + Haskoin.Keys.Mnemonic + Haskoin.Network.Bloom + Haskoin.Network.Common + Haskoin.Network.Message + Haskoin.Script.Common + Haskoin.Script.SigHash + Haskoin.Script.Standard + Haskoin.Transaction.Builder + Haskoin.Transaction.Builder.Sign + Haskoin.Transaction.Common + Haskoin.Transaction.Partial + Haskoin.Transaction.Segwit + Paths_haskoin_core + hs-source-dirs: + src + build-depends: + aeson >=1.4.6.0 + , array >=0.5.4.0 + , base >=4.9 && <5 + , base16-bytestring >=0.1.1.6 + , bytestring >=0.10.10.0 + , cereal >=0.5.8.1 + , conduit >=1.3.1.2 + , containers >=0.6.2.1 + , cryptonite >=0.26 + , deepseq >=1.4.4.0 + , entropy >=0.4.1.5 + , hashable >=1.3.0.0 + , memory >=0.15.0 + , mtl >=2.2.2 + , murmur3 >=1.0.3 + , network >=3.1.1.1 + , safe >=0.3.18 + , scientific >=0.3.6.2 + , secp256k1-haskell >=0.2.1 + , split >=0.2.3.3 + , string-conversions >=0.4.0.1 + , text >=1.2.4.0 + , time >=1.9.3 + , transformers >=0.5.6.2 + , unordered-containers >=0.2.10.0 + , vector >=0.12.1.2 + default-language: Haskell2010 + +test-suite spec + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Haskoin.Address.Bech32Spec + Haskoin.Address.CashAddrSpec + Haskoin.AddressSpec + Haskoin.BlockSpec + Haskoin.Crypto.HashSpec + Haskoin.Crypto.SignatureSpec + Haskoin.CryptoSpec + Haskoin.Keys.ExtendedSpec + Haskoin.Keys.MnemonicSpec + Haskoin.KeysSpec + Haskoin.NetworkSpec + Haskoin.ScriptSpec + Haskoin.Test + Haskoin.Test.Address + Haskoin.Test.Block + Haskoin.Test.Crypto + Haskoin.Test.Keys + Haskoin.Test.Message + Haskoin.Test.Network + Haskoin.Test.Script + Haskoin.Test.Transaction + Haskoin.Test.Util + Haskoin.Transaction.PartialSpec + Haskoin.TransactionSpec + Haskoin.UtilSpec + Haskoin + Haskoin.Address + Haskoin.Address.Base58 + Haskoin.Address.Bech32 + Haskoin.Address.CashAddr + Haskoin.Block + Haskoin.Block.Common + Haskoin.Block.Headers + Haskoin.Block.Merkle + Haskoin.Constants + Haskoin.Crypto + Haskoin.Crypto.Hash + Haskoin.Crypto.Signature + Haskoin.Keys + Haskoin.Keys.Common + Haskoin.Keys.Extended + Haskoin.Keys.Mnemonic + Haskoin.Network + Haskoin.Network.Bloom + Haskoin.Network.Common + Haskoin.Network.Message + Haskoin.Script + Haskoin.Script.Common + Haskoin.Script.SigHash + Haskoin.Script.Standard + Haskoin.Transaction + Haskoin.Transaction.Builder + Haskoin.Transaction.Builder.Sign + Haskoin.Transaction.Common + Haskoin.Transaction.Partial + Haskoin.Transaction.Segwit + Haskoin.Util + Paths_haskoin_core + hs-source-dirs: + test + src + build-depends: + HUnit >=1.6.0.0 + , QuickCheck >=2.13.2 + , aeson >=1.4.6.0 + , array >=0.5.4.0 + , base >=4.9 && <5 + , base16-bytestring >=0.1.1.6 + , bytestring >=0.10.10.0 + , cereal >=0.5.8.1 + , conduit >=1.3.1.2 + , containers >=0.6.2.1 + , cryptonite >=0.26 + , deepseq >=1.4.4.0 + , entropy >=0.4.1.5 + , hashable >=1.3.0.0 + , hspec >=2.7.1 + , memory >=0.15.0 + , mtl >=2.2.2 + , murmur3 >=1.0.3 + , network >=3.1.1.1 + , safe >=0.3.18 + , scientific >=0.3.6.2 + , secp256k1-haskell >=0.2.1 + , split >=0.2.3.3 + , string-conversions >=0.4.0.1 + , text >=1.2.4.0 + , time >=1.9.3 + , transformers >=0.5.6.2 + , unordered-containers >=0.2.10.0 + , vector >=0.12.1.2 + default-language: Haskell2010 + build-tool-depends: hspec-discover:hspec-discover diff --git a/package.yaml b/package.yaml index aabdecc8..73631ef2 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: haskoin-core -version: 0.13.3 +version: 0.13.4 synopsis: Bitcoin & Bitcoin Cash library for Haskell description: 'Haskoin Core is a complete Bitcoin and Bitcoin Cash library of functions and data types for Haskell developers.' category: Bitcoin, Finance, Network diff --git a/src/Haskoin/Script/Common.hs b/src/Haskoin/Script/Common.hs index ee460e26..574cba99 100644 --- a/src/Haskoin/Script/Common.hs +++ b/src/Haskoin/Script/Common.hs @@ -214,6 +214,8 @@ data ScriptOp -- Bitcoin Cash Nov 2018 hard fork | OP_CHECKDATASIG | OP_CHECKDATASIGVERIFY + -- Bitcoin Cash May 2020 hard fork + | OP_REVERSEBYTES -- Other | OP_PUBKEYHASH | OP_PUBKEY @@ -367,6 +369,9 @@ instance Serialize ScriptOp where | op == 0xba = return OP_CHECKDATASIG | op == 0xbb = return OP_CHECKDATASIGVERIFY + -- Bitcoin Cash May 2020 hard fork + | op == 0xbc = return OP_REVERSEBYTES + -- Constants | op == 0xfd = return OP_PUBKEYHASH | op == 0xfe = return OP_PUBKEY @@ -534,6 +539,9 @@ instance Serialize ScriptOp where OP_CHECKDATASIG -> putWord8 0xba OP_CHECKDATASIGVERIFY -> putWord8 0xbb + -- Bitcoin Cash May 2020 hard fork + OP_REVERSEBYTES -> putWord8 0xbc + -- | Check whether opcode is only data. isPushOp :: ScriptOp -> Bool diff --git a/test/Haskoin/ScriptSpec.hs b/test/Haskoin/ScriptSpec.hs index 6b29ffb1..d2b29d58 100644 --- a/test/Haskoin/ScriptSpec.hs +++ b/test/Haskoin/ScriptSpec.hs @@ -10,7 +10,6 @@ import Data.Either import Data.List import Data.Map.Strict (singleton) import Data.Maybe -import Data.Monoid ((<>)) import Data.Serialize as S import Data.String import Data.String.Conversions (cs) diff --git a/test/Haskoin/Test/Script.hs b/test/Haskoin/Test/Script.hs index 5bdfacc5..4a1849ea 100644 --- a/test/Haskoin/Test/Script.hs +++ b/test/Haskoin/Test/Script.hs @@ -149,6 +149,11 @@ arbitraryScriptOp = , return OP_NOP8 , return OP_NOP9 , return OP_NOP10 + -- Bitcoin Cash Nov 2018 hard fork + , return OP_CHECKDATASIG + , return OP_CHECKDATASIGVERIFY + -- Bitcoin Cash May 2020 hard fork + , return OP_REVERSEBYTES -- Other , return OP_PUBKEYHASH , return OP_PUBKEY