packages feed

bitcoin-api 0.10.0 → 0.11.0

raw patch · 3 files changed

+6/−90 lines, 3 filesdep −conduitdep −stmdep −stm-chans

Dependencies removed: conduit, stm, stm-chans, stm-conduit, transformers

Files

bitcoin-api.cabal view
@@ -1,20 +1,20 @@ name: bitcoin-api
 category: Network, Finance
-version: 0.10.0
+version: 0.11.0
 license: MIT
 license-file: LICENSE
 copyright: (c) 2015 Leon Mergen
 author: Leon Mergen
 maintainer: leon@solatis.com
 homepage: http://www.leonmergen.com/opensource.html
-bug-reports: http://github.com/solatis/haskell-bitcoin-script/issues
+bug-reports: http://github.com/solatis/haskell-bitcoin-api/issues
 stability: experimental
 synopsis: Provides access to the RPC API of Bitcoin Core
 description:
    The Bitcoin Core application provides an HTTP RPC interface for communication.
    This library implements access to these functions. It builds on top of the
    `bitcoin-tx` and `bitcoin-script`, and as such provides an extremely flexible
-   environment to create, manipulate and store transactions and custom scripts.         
+   environment to create, manipulate and store transactions and custom scripts.
                       
 build-type: Simple
 data-files: LICENSE, README.md
@@ -50,11 +50,6 @@                      , lens-aeson
                      , unordered-containers
                      , wreq
-                     , conduit
-                     , transformers
-                     , stm
-                     , stm-chans
-                     , stm-conduit
 
                      , bitcoin-types
                      , bitcoin-block
@@ -86,8 +81,7 @@                      , http-client
                      , wreq                     
                      , lens
-                     , conduit
-                     
+                                          
                      , hspec
                      
                      , bitcoin-tx
@@ -96,5 +90,5 @@ 
 source-repository head
   type: git
-  location: git://github.com/solatis/haskell-bitcoin-script.git
+  location: git://github.com/solatis/haskell-bitcoin-api.git
   branch: master
src/Network/Bitcoin/Api/Transaction.hs view
@@ -12,19 +12,8 @@ import           Data.Maybe                                   (fromMaybe)
 
 import           Control.Lens                                 ((^.), (^?))
-import qualified Data.Conduit                                 as C (Source)
 
-import           Control.Concurrent                           (forkIO,
-                                                               killThread,
-                                                               myThreadId,
-                                                               threadDelay)
-import           Control.Concurrent.STM.TBMQueue              (isClosedTBMQueue,
-                                                               newTBMQueue,
-                                                               writeTBMQueue)
 import           Control.Monad                                (unless)
-import           Control.Monad.IO.Class                       (liftIO)
-import           Control.Monad.STM                            (atomically)
-import           Data.Conduit.TQueue                          (sourceTBMQueue)
 
 import qualified Data.Base58String                            as B58S
 import qualified Data.Bitcoin.Block                           as Btc (Block (..))
@@ -140,54 +129,3 @@   blocks <- mapM (Blockchain.getBlock client) =<< mapM (Blockchain.getBlockHash client) [offset..limit - confirmations]
 
   return $ foldl (\lhs rhs -> lhs ++ Btc.blockTxns rhs) [] blocks
-
--- | Watches incoming transactions and yields new transactions as soon as they
---   are are inside a block. Note that this launches a background thread which
---   stops as soon as the Conduit is closed.
-watch :: T.Client                    -- ^ Our client session context
-      -> Maybe Integer               -- ^ Minimum amount of confirmations. Should be 1 or higher. A default value of 6 is used.
-      -> C.Source IO Btc.Transaction -- ^ Conduit that generates transactions
-watch client Nothing              = watch client (Just 6)
-watch client (Just confirmations) = do
-  chan      <- liftIO $ atomically $ newTBMQueue 16
-  curHeight <- liftIO blockHeight
-  _         <- liftIO $ forkIO $ watchNext chan curHeight
-
-  sourceTBMQueue chan
-
-  where
-
-    -- | Calculates the height of the block we currently are looking for
-    blockHeight = do
-      limit <- Blockchain.getBlockCount client
-      return (limit - confirmations)
-
-    -- | Watches the current height of the block chain, and continues only
-    --   when the height changes.
-    watchNext chan height = do
-      cur <- blockHeight
-
-      if cur > height
-        then go chan (height + 1)
-        else threadDelay 1000000 >> watchNext chan height
-
-    -- | Fills the chan with all transactions from the block at `height`,
-    --   and then continues waiting until a next block is available.
-    go chan height = do
-      block <- Blockchain.getBlock client =<< Blockchain.getBlockHash client height
-      tid   <- myThreadId
-
-
-      result <- mapM (insert chan) (Btc.blockTxns block)
-      let isClosed = False `elem` result
-
-      if isClosed
-        then killThread tid
-        else watchNext chan height
-
-    -- | Inserts a transaction into the queue. Blocks if the queue is full.
-    --   Returns True if write succeeded, False is the queue was closed.
-    insert chan tx = atomically $ do
-      isClosed <- isClosedTBMQueue chan
-      unless isClosed (writeTBMQueue chan tx)
-      return isClosed
test/Network/Bitcoin/Api/TestUtil.hs view
@@ -1,27 +1,11 @@ module Network.Bitcoin.Api.TestUtil (testClient, isStatusCodeException) where
 
-import qualified Data.Bitcoin.Script                          as Btc
-import qualified Data.Bitcoin.Transaction                     as Btc
-import qualified Data.List                                    as L (find)
-import           Data.Maybe                                   (isJust, mapMaybe)
-
 import qualified Data.Text                                    as T (pack)
 import           Control.Lens                                 ((^.))
-
 import           Network.HTTP.Client                          (HttpException (..))
-
-import           Network.Bitcoin.Api.Client
-
-import qualified Network.Bitcoin.Api.Blockchain               as Blockchain
-import qualified Network.Bitcoin.Api.Dump                     as Dump
-import qualified Network.Bitcoin.Api.Mining                   as Mining
-import qualified Network.Bitcoin.Api.Misc                     as Misc
-import qualified Network.Bitcoin.Api.Transaction              as Transaction
-import           Network.Bitcoin.Api.Types.UnspentTransaction (address, amount)
-import qualified Network.Bitcoin.Api.Wallet                   as Wallet
 import           Network.Wreq.Lens                            (statusCode)
 
-import           Test.Hspec
+import           Network.Bitcoin.Api.Client
 
 testClient :: (Client -> IO a) -> IO a
 testClient = withClient "127.0.0.1" 18332 (T.pack "user") (T.pack "pass")