Skip to content

Commit

Permalink
Fix witness decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
jprupp committed Jun 8, 2021
1 parent 73fcd3c commit 1471523
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions haskoin-core.cabal
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
@@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Haskoin/Address.hs
Expand Up @@ -19,6 +19,7 @@ module Haskoin.Address
Address(..)
, isPubKeyAddress
, isScriptAddress
, isWitnessAddress
, isWitnessPubKeyAddress
, isWitnessScriptAddress
, addrToText
Expand Down
3 changes: 1 addition & 2 deletions src/Haskoin/Keys/Common.hs
Expand Up @@ -34,7 +34,6 @@ module Haskoin.Keys.Common
, toWif
) where

import Control.Applicative ((<|>))
import Control.DeepSeq
import Control.Monad (guard, mzero, (<=<))
import Crypto.Secp256k1
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Haskoin/Network/Common.hs
Expand Up @@ -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 =
Expand Down
4 changes: 3 additions & 1 deletion src/Haskoin/Script/Standard.hs
Expand Up @@ -20,6 +20,7 @@ module Haskoin.Script.Standard
, isPayPKHash
, isPayMulSig
, isPayScriptHash
, isPayWitness
, isPayWitnessPKHash
, isPayWitnessScriptHash
, isDataCarrier
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1471523

Please sign in to comment.