packages feed

network-bitcoin 0.1.3 → 0.1.4

raw patch · 2 files changed

+27/−19 lines, 2 filesdep ~HTTPdep ~aesondep ~attoparsec

Dependency ranges changed: HTTP, aeson, attoparsec, bytestring, containers, network, text

Files

network-bitcoin.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.1.3+Version:             0.1.4  -- A short (one-line) description of the package. Synopsis:            Interface with Bitcoin RPC@@ -28,13 +28,9 @@     .     To learn more about Bitcoin, see <http://www.bitcoin.org>.     .-    Changes in v0.1.3-    .-    - Be more lenient when accepting addresses-    .-    - Support testnet addresses+    Changes in v0.1.4     .-    - Add FlexibleInstances for GHC 7.2+    - More accurate conversion of Bitcoin amounts from floating point  -- The license under which the package is released. License:             BSD3@@ -65,7 +61,7 @@ -- Extra-source-files:    -- Constraint on the version of Cabal needed to build this package.-Cabal-version:       >=1.6+Cabal-version:       >=1.8   Library@@ -79,13 +75,13 @@      -- Packages needed in order to build this package.   Build-depends:       -    aeson == 0.3.*,-    attoparsec >= 0.7 && < 0.10,-    bytestring == 0.9.*,-    containers == 0.4.*,-    HTTP == 4000.*,-    network == 2.3.*,-    text == 0.11.*,+    aeson >= 0.3,+    attoparsec >= 0.7,+    bytestring >= 0.9,+    containers >= 0.4,+    HTTP >= 4000,+    network >= 2.3,+    text >= 0.11,     base == 4.*      -- Modules not exported by this package.@@ -93,6 +89,10 @@      -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.   -- Build-tools:         ++Test-suite test-main+    type: exitcode-stdio-1.0+    main-is: test-main.hs    Source-repository head     type: git
src/Network/Bitcoin.hs view
@@ -17,6 +17,7 @@     , isMine     , account     , BitcoinException(..)+    , Satoshi(..)      -- * Individual API methods     , getBalance@@ -32,6 +33,8 @@      -- * Low-level API     , callApi+    , FromNumber+    , fromNumber     ) where import Network.Bitcoin.Address @@ -43,6 +46,7 @@ import Data.Attoparsec.Number import Data.Fixed import Data.Maybe (fromJust)+import Data.Ratio ((%)) import Data.String (fromString) import Data.Typeable import Network.Browser@@ -53,10 +57,12 @@ import qualified Data.Map as M import qualified Data.Text as T --- Define Bitcoin's internal precision+-- | Defines Bitcoin's internal precision+satoshis :: Integer+satoshis = 10^(8::Integer) data Satoshi = Satoshi instance HasResolution Satoshi where-    resolution _ = 10^(8::Integer)+    resolution _ = satoshis  -- | Fixed precision Bitcoin amount (to avoid floating point errors) type Amount = Fixed Satoshi@@ -167,12 +173,14 @@           msg  = find "message" o buildBtcError _ = error "Need an object to buildBtcError" --- Convert JSON numeric values to more specific numeric types+-- | Convert JSON numeric values to more specific numeric types class FromNumber a where     fromNumber :: Number -> a instance FromNumber Amount where     fromNumber (I i) = fromInteger i-    fromNumber (D d) = fromRational $ toRational d+    fromNumber (D d) = fromRational $ numerator % satoshis+      where+        numerator = round $ d * (fromInteger satoshis) instance FromNumber Integer where     fromNumber (I i) = i     fromNumber (D d) = round d