Fix witness decoder

This commit is contained in:
JP Rupp 2021-06-08 16:09:57 +01:00
parent 73fcd3c401
commit 147152343c
No known key found for this signature in database
GPG Key ID: 93391726EAFA0C5D
7 changed files with 13 additions and 7 deletions

View File

@ -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.20.4
### Fixed
- Add missing case for witness version.
## 0.20.3
### Fixed
- Allow unknown inv types.

View File

@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 51a1645e2f8c2dc54a6cc91c03a262683a314702f2ffbc182667967b50e88f6f
-- hash: d57876572e143601ab9185c42f47f703460c4e8396b846f805068a5cff8fec3e
name: haskoin-core
version: 0.20.3
version: 0.20.4
synopsis: Bitcoin & Bitcoin Cash library for Haskell
description: Please see the README on GitHub at <https://github.com/haskoin/haskoin-core#readme>
category: Bitcoin, Finance, Network

View File

@ -1,5 +1,5 @@
name: haskoin-core
version: 0.20.3
version: 0.20.4
synopsis: Bitcoin & Bitcoin Cash library for Haskell
description: Please see the README on GitHub at <https://github.com/haskoin/haskoin-core#readme>
category: Bitcoin, Finance, Network

View File

@ -19,6 +19,7 @@ module Haskoin.Address
Address(..)
, isPubKeyAddress
, isScriptAddress
, isWitnessAddress
, isWitnessPubKeyAddress
, isWitnessScriptAddress
, addrToText

View File

@ -34,7 +34,6 @@ module Haskoin.Keys.Common
, toWif
) where
import Control.Applicative ((<|>))
import Control.DeepSeq
import Control.Monad (guard, mzero, (<=<))
import Crypto.Secp256k1
@ -80,7 +79,7 @@ instance ToJSON PubKeyI where
instance FromJSON PubKeyI where
parseJSON = withText "PubKeyI" $
maybe mzero return . (eitherToMaybe . runGetS deserialize =<<) . decodeHex
maybe mzero return . ((eitherToMaybe . runGetS deserialize) <=< decodeHex)
instance Serial PubKeyI where
deserialize = s >>= \case

View File

@ -493,7 +493,7 @@ instance Serial VarInt where
go 0xff = getWord64le
go 0xfe = fromIntegral <$> getWord32le
go 0xfd = fromIntegral <$> getWord16le
go x = fromIntegral <$> return x
go x = return $ fromIntegral x
serialize (VarInt x)
| x < 0xfd =

View File

@ -20,6 +20,7 @@ module Haskoin.Script.Standard
, isPayPKHash
, isPayMulSig
, isPayScriptHash
, isPayWitness
, isPayWitnessPKHash
, isPayWitnessScriptHash
, isDataCarrier
@ -56,7 +57,7 @@ import Data.Bytes.Serial
import Data.Function (on)
import Data.Hashable
import Data.List (sortBy)
import Data.Maybe (fromJust, isJust, isNothing)
import Data.Maybe (fromJust, isJust)
import Data.Word (Word8)
import GHC.Generics (Generic)
import Haskoin.Constants
@ -189,6 +190,7 @@ witnessVersionOp 13 = Just OP_13
witnessVersionOp 14 = Just OP_14
witnessVersionOp 15 = Just OP_15
witnessVersionOp 16 = Just OP_16
witnessVersionOp _ = Nothing
opWitnessVersion :: ScriptOp -> Maybe Word8
opWitnessVersion OP_0 = Just 0