Skip to content

Commit

Permalink
updates:
Browse files Browse the repository at this point in the history
- removes incorrect field from estimateSmartFee return value
- updates OutputInfo for v0.17
  • Loading branch information
GambolingPangolin committed Mar 7, 2019
1 parent 91d812f commit 22984ab
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ cabal-dev/
network-bitcoin-tests
cabal.sandbox.config
.cabal-sandbox/
tags
1 change: 1 addition & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ dist-newstyle/
\.tfstate\.blank$
\.terraform/
\.stack-work/
^tags$
4 changes: 2 additions & 2 deletions src/Network/Bitcoin/BlockChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ data OutputInfo =
-- | The public key of the sender.
, oiScriptPubKey :: ScriptPubKey
-- | The version of this transaction.
, oiVersion :: Integer
, oiVersion :: Maybe Integer
-- | Is this transaction part of the coin base?
, oiCoinBase :: Bool
}
Expand All @@ -163,7 +163,7 @@ instance FromJSON OutputInfo where
<*> o .: "confirmations"
<*> o .: "value"
<*> o .: "scriptPubKey"
<*> o .: "version"
<*> o .:? "version"
<*> o .: "coinbase"
parseJSON _ = mzero

Expand Down
8 changes: 4 additions & 4 deletions src/Network/Bitcoin/RawTransaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ instance FromJSON UnspentTransaction where

-- Instance used in 'createRawTransaction'.
instance ToJSON UnspentTransaction where
toJSON (UnspentTransaction{..}) = object [ "txid" .= unspentTransactionId
, "vout" .= outIdx
]
toJSON UnspentTransaction{..} = object [ "txid" .= unspentTransactionId
, "vout" .= outIdx
]

-- | Returns an array of unspent transaction outputs with between minconf and
-- maxconf (inclusive) confirmations. If addresses are given, the result will
Expand Down Expand Up @@ -306,7 +306,7 @@ decodeRawTransaction client tx = callApi client "decoderawtransaction" [ tj tx ]
newtype UnspentForSigning = UFS UnspentTransaction

instance ToJSON UnspentForSigning where
toJSON (UFS (UnspentTransaction{..}))
toJSON (UFS UnspentTransaction{..})
| isNothing redeemScript =
object [ "txid" .= unspentTransactionId
, "vout" .= outIdx
Expand Down
7 changes: 3 additions & 4 deletions src/Network/Bitcoin/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ module Network.Bitcoin.Wallet ( Client
, isAddressValid
) where

import Control.Applicative (liftA2)
import Control.Monad
import Data.Aeson as A
import Data.Aeson.Types (parseEither)
Expand All @@ -78,7 +77,7 @@ import Data.Text
import Data.Time.Clock.POSIX
import Data.Vector as V hiding ((++))
import Data.Word
import Network.Bitcoin.BlockChain (BlockHash, BlockHeight)
import Network.Bitcoin.BlockChain (BlockHash)
import Network.Bitcoin.Internal
import Network.Bitcoin.RawTransaction (RawTransaction)

Expand Down Expand Up @@ -770,7 +769,7 @@ instance ToJSON EstimationMode where


-- | Estimate the fee per kb to send a transaction
estimateSmartFee :: Client -> Word32 -> Maybe EstimationMode -> IO (Either [String] (Double, BlockHeight))
estimateSmartFee :: Client -> Word32 -> Maybe EstimationMode -> IO (Either [String] Double)
estimateSmartFee client target mode =
parse <$> callApi client "estimatesmartfee" (catMaybes [ Just $ tj target, tj <$> mode ])
where
Expand All @@ -779,4 +778,4 @@ estimateSmartFee client target mode =
merrs <- obj .:? "errors"
flip (maybe (parseVals obj)) merrs $ \errs ->
bool (pure $ Left errs) (parseVals obj) . List.null $ errs
parseVals = fmap Right . (liftA2 (,) <$> (.: "feerate") <*> (.: "blocks"))
parseVals = fmap Right . (.: "feerate")

0 comments on commit 22984ab

Please sign in to comment.