bitcoin-api 0.11.1 → 0.12.0
raw patch · 5 files changed
+15/−4 lines, 5 files
Files
- bitcoin-api.cabal +1/−1
- src/Network/Bitcoin/Api/Transaction.hs +0/−2
- src/Network/Bitcoin/Api/Wallet.hs +9/−0
- test/Network/Bitcoin/Api/MiscSpec.hs +1/−1
- test/Network/Bitcoin/Api/WalletSpec.hs +4/−0
bitcoin-api.cabal view
@@ -1,6 +1,6 @@ name: bitcoin-api category: Network, Finance -version: 0.11.1 +version: 0.12.0 license: MIT license-file: LICENSE copyright: (c) 2015 Leon Mergen
src/Network/Bitcoin/Api/Transaction.hs view
@@ -13,8 +13,6 @@ import Control.Lens ((^.), (^?)) -import Control.Monad (unless) - import qualified Data.Base58String as B58S import qualified Data.Bitcoin.Block as Btc hiding (encode, decode) import qualified Data.Bitcoin.Transaction as Btc
src/Network/Bitcoin/Api/Wallet.hs view
@@ -44,6 +44,15 @@ in return . HM.toList =<< I.call client "listaccounts" configuration +-- | Returns the amount of Btc currently held in the wallet by a specified +-- account. +getAccountBalance :: T.Client -- | Our client context + -> BT.Account -- | The account we're looking for + -> IO BT.Btc -- | Amount of Btc in wallet +getAccountBalance client accountId = + -- FIXME: we should use the native 'getbalance' function here + return . snd . head . filter ((== accountId) . fst) =<< listAccounts client + -- | Provides access to a new receiving address filed under the default account. -- Intended to be published to another party that wishes to send you money. newAddress :: T.Client -- ^ Our client context
test/Network/Bitcoin/Api/MiscSpec.hs view
@@ -13,5 +13,5 @@ it "should be able to return server info" $ do r <- testClient Misc.getInfo - r ^. Misc.bitcoinVersion `shouldBe` 100100 + r ^. Misc.bitcoinVersion `shouldBe` 100200 r ^. Misc.bitcoindErrors `shouldBe` (T.pack "")
test/Network/Bitcoin/Api/WalletSpec.hs view
@@ -37,6 +37,10 @@ list <- Wallet.listAccounts client L.find (\(needle, _) -> needle == T.pack "testAccount") list `shouldSatisfy` isJust + -- Extra validation that we can look up the balance of the account + balance <- Wallet.getAccountBalance client (T.pack "testAccount") + balance `shouldBe` 0 + it "should be able to create a change address" $ do testClient $ \client -> do addr <- Wallet.newChangeAddress client