packages feed

haskoin-core 0.13.0 → 0.13.1

raw patch · 6 files changed

+45/−17 lines, 6 files

Files

CHANGELOG.md view
@@ -4,6 +4,10 @@ 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.1+### Changed+- Faster JSON serialization.+ ## 0.13.0 ### Changed - Consolidate all modules in Haskoin module.
haskoin-core.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: cb3995ebfc2aec471903f82fb6188dbb64f40fadf01471080ccf6a7948a3f7c4+-- hash: ad4c6376deb0bf12b7271c03f9d6602888452d75a32a16f711ef2f018b500a10  name:           haskoin-core-version:        0.13.0+version:        0.13.1 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
src/Network/Haskoin/Block/Common.hs view
@@ -31,12 +31,14 @@ import           Control.DeepSeq import           Control.Monad                      (forM_, liftM2, mzero,                                                      replicateM)-import           Data.Aeson                         (FromJSON, ToJSON,-                                                     Value (String), parseJSON,-                                                     toJSON, withText)+import           Data.Aeson                         (FromJSON (..), ToJSON (..),+                                                     Value (String), toJSON,+                                                     withText)+import           Data.Aeson.Encoding                (unsafeToEncoding) import           Data.Bits                          (shiftL, shiftR, (.&.),                                                      (.|.)) import qualified Data.ByteString                    as B+import           Data.ByteString.Builder            (char7) import           Data.Hashable                      (Hashable) import           Data.Maybe                         (fromMaybe) import           Data.Serialize                     (Serialize, decode, encode,@@ -79,6 +81,8 @@  instance ToJSON Block where     toJSON = String . encodeHex . encode+    toEncoding s =+        unsafeToEncoding $ char7 '"' <> hexBuilder (encode s) <> char7 '"'  instance FromJSON Block where     parseJSON =@@ -93,6 +97,8 @@  instance ToJSON BlockHeader where     toJSON = String . encodeHex . encode+    toEncoding s =+        unsafeToEncoding $ char7 '"' <> hexBuilder (encode s) <> char7 '"'  instance FromJSON BlockHeader where     parseJSON =@@ -129,6 +135,9 @@  instance ToJSON BlockHash where     toJSON = String . blockHashToHex+    toEncoding s =+        unsafeToEncoding $+        char7 '"' <> hexBuilder (B.reverse (encode s)) <> char7 '"'  -- | Block hashes are reversed with respect to the in-memory byte order in a -- block hash when displayed.
src/Network/Haskoin/Keys.hs view
@@ -10,9 +10,13 @@ (BIP-39). -} module Network.Haskoin.Keys-    ( module X+    ( module Network.Haskoin.Keys.Common+    -- * Extended Keys+    , module Network.Haskoin.Keys.Extended+    -- * Mnemonic+    , module Network.Haskoin.Keys.Mnemonic     ) where -import           Network.Haskoin.Keys.Common   as X-import           Network.Haskoin.Keys.Extended as X-import           Network.Haskoin.Keys.Mnemonic as X+import           Network.Haskoin.Keys.Common+import           Network.Haskoin.Keys.Extended+import           Network.Haskoin.Keys.Mnemonic
src/Network/Haskoin/Keys/Common.hs view
@@ -35,10 +35,13 @@ import           Control.DeepSeq import           Control.Monad               (guard, mzero, (<=<)) import           Crypto.Secp256k1-import           Data.Aeson                  (FromJSON, ToJSON, Value (String),-                                              parseJSON, toJSON, withText)+import           Data.Aeson                  (FromJSON, ToJSON (..),+                                              Value (String), parseJSON,+                                              withText)+import           Data.Aeson.Encoding         (unsafeToEncoding) import           Data.ByteString             (ByteString) import qualified Data.ByteString             as BS+import           Data.ByteString.Builder     (char7) import           Data.Hashable import           Data.Maybe                  (fromMaybe) import           Data.Serialize              (Serialize, decode, encode, get,@@ -65,6 +68,7 @@  instance ToJSON PubKeyI where     toJSON = String . encodeHex . encode+    toEncoding s = unsafeToEncoding $ char7 '"' <> hexBuilder (encode s) <> char7 '"'  instance FromJSON PubKeyI where     parseJSON = withText "PubKeyI" $
src/Network/Haskoin/Keys/Extended.hs view
@@ -40,9 +40,11 @@     , xPubCompatWitnessAddr     , xPubExport     , xPubToJSON+    , xPubToEncoding     , xPubFromJSON     , xPrvExport     , xPrvToJSON+    , xPrvToEncoding     , xPrvFromJSON     , xPubImport     , xPrvImport@@ -104,9 +106,10 @@ import           Control.Exception              (Exception, throw) import           Control.Monad                  (guard, mzero, unless, (<=<)) import           Crypto.Secp256k1-import           Data.Aeson                     as A (FromJSON, ToJSON,+import           Data.Aeson                     as A (FromJSON, ToJSON (..),                                                       Value (String), parseJSON,                                                       toJSON, withText)+import           Data.Aeson.Encoding            (Encoding, text) import           Data.Aeson.Types               (Parser) import           Data.Bits                      (clearBit, setBit, testBit) import           Data.ByteString                (ByteString)@@ -115,7 +118,6 @@ import           Data.List                      (foldl') import           Data.List.Split                (splitOn) import           Data.Maybe                     (fromMaybe)-import           Data.Monoid                    ((<>)) import           Data.Serialize                 as S (Serialize, decode, encode,                                                       get, put) import           Data.Serialize.Get             (Get, getWord32be, getWord8,@@ -128,7 +130,6 @@ import           Data.Word                      (Word32, Word8) import           GHC.Generics                   (Generic) import           Network.Haskoin.Address-import           Network.Haskoin.Address.Base58 import           Network.Haskoin.Constants import           Network.Haskoin.Crypto.Hash import           Network.Haskoin.Keys.Common@@ -168,6 +169,9 @@ xPrvToJSON :: Network -> XPrvKey -> Value xPrvToJSON net = A.String . xPrvExport net +xPrvToEncoding :: Network -> XPrvKey -> Encoding+xPrvToEncoding net = text . xPrvExport net+ -- | Data type representing an extended BIP32 public key. data XPubKey = XPubKey     { xPubDepth  :: !Word8     -- ^ depth in the tree@@ -190,6 +194,9 @@ xPubToJSON :: Network -> XPubKey -> Value xPubToJSON net = A.String . xPubExport net +xPubToEncoding :: Network -> XPubKey -> Encoding+xPubToEncoding net = text . xPubExport net+ -- | Decode an extended private key from a JSON string xPrvFromJSON :: Network -> Value -> Parser XPrvKey xPrvFromJSON net =@@ -538,7 +545,7 @@ instance NFData (DerivPathI t) where     rnf (a :| b) = rnf a `seq` rnf b `seq` ()     rnf (a :/ b) = rnf a `seq` rnf b `seq` ()-    rnf Deriv = ()+    rnf Deriv    = ()  instance Eq (DerivPathI t) where     (nextA :| iA) == (nextB :| iB) = iA == iB && nextA == nextB@@ -554,9 +561,9 @@         if nextA == nextB then iA `compare` iB else nextA `compare` nextB      -- Different hardness: hard paths are LT soft paths-    (nextA :/ iA) `compare` (nextB :| iB) =+    (nextA :/ _iA) `compare` (nextB :| _iB) =         if nextA == nextB then LT else nextA `compare` nextB-    (nextA :| iA) `compare` (nextB :/ iB) =+    (nextA :| _iA) `compare` (nextB :/ _iB) =         if nextA == nextB then GT else nextA `compare` nextB      Deriv `compare` Deriv  = EQ