-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Provides access to the RPC API of Bitcoin Core
--   
--   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.
@package bitcoin-api
@version 0.12.1

module Network.Bitcoin.Api.Types.UnspentTransaction

-- | A transaction that is not yet spent. Every output transaction relies
--   on one or more unspent input transansactions.
--   
--   For more detailed documentation of the fields, see:
--   <a>https://bitcoin.org/en/developer-reference#listunspent</a>
data UnspentTransaction
UnspentTransaction :: Btc -> TransactionId -> Integer -> Bool -> Maybe Base58String -> Maybe Text -> Integer -> Text -> Maybe Text -> UnspentTransaction

-- | The transaction amount in <a>Btc</a>
[_amount] :: UnspentTransaction -> Btc

-- | Transaction identifier to uniquely identify the transaction.
[_transactionId] :: UnspentTransaction -> TransactionId

-- | The index of the output of the transaction that has been spent.
[_vout] :: UnspentTransaction -> Integer

-- | Whether this input is spendable. If not, it means it is an output of a
--   watch-only address.
[_spendable] :: UnspentTransaction -> Bool

-- | The P2PKH or P2SH address this transaction belongs to. Only available
--   in case of P2PKH or P2SH output scripts.
[_address] :: UnspentTransaction -> Maybe Base58String

-- | If the address belongs to an account, the account is returned.
[_account] :: UnspentTransaction -> Maybe Text

-- | The amount of confirmations this transaction has
[_confirmations] :: UnspentTransaction -> Integer

-- | The output script paid, encoded as hex
[_scriptPubKey] :: UnspentTransaction -> Text

-- | If the output is a P2SH whose script belongs to this wallet, this is
--   the redeem script.
[_redeemScript] :: UnspentTransaction -> Maybe Text
vout :: Lens' UnspentTransaction Integer
transactionId :: Lens' UnspentTransaction TransactionId
spendable :: Lens' UnspentTransaction Bool
scriptPubKey :: Lens' UnspentTransaction Text
redeemScript :: Lens' UnspentTransaction (Maybe Text)
confirmations :: Lens' UnspentTransaction Integer
amount :: Lens' UnspentTransaction Btc
address :: Lens' UnspentTransaction (Maybe Base58String)
account :: Lens' UnspentTransaction (Maybe Text)
instance Data.Aeson.Types.FromJSON.FromJSON Network.Bitcoin.Api.Types.UnspentTransaction.UnspentTransaction
instance GHC.Show.Show Network.Bitcoin.Api.Types.UnspentTransaction.UnspentTransaction

module Network.Bitcoin.Api.Types

-- | Client session data
data Client
Client :: String -> Options -> Session -> Client

-- | The JSON RPC url
[clientUrl] :: Client -> String

-- | Default HTTP options to use with <tt>wreq</tt> requests
[clientOpts] :: Client -> Options

-- | Connection reuse of our HTTP session
[clientSession] :: Client -> Session
instance GHC.Show.Show Network.Bitcoin.Api.Types.Client

module Network.Bitcoin.Api.Misc
data BitcoinInfo
BitcoinInfo :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Text -> Double -> Bool -> Integer -> Integer -> Integer -> Maybe Integer -> Text -> BitcoinInfo

-- | What version of bitcoind are we running?
[_bitcoinVersion] :: BitcoinInfo -> Integer

-- | What is bitcoind's current protocol number?
[_protocolVersion] :: BitcoinInfo -> Integer

-- | What version is the wallet?
[_walletVersion] :: BitcoinInfo -> Integer

-- | How much money is currently in the wallet?
[_balance] :: BitcoinInfo -> Integer

-- | The number of blocks in our chain.
[_numBlocks] :: BitcoinInfo -> Integer

-- | How many peers are we connected to?
[_numConnections] :: BitcoinInfo -> Integer

-- | A blank string if we're not using a proxy.
[_proxy] :: BitcoinInfo -> Text

-- | The difficulty multiplier for bitcoin mining operations.
[_generationDifficulty] :: BitcoinInfo -> Double

-- | Are we on the test network (as opposed to the primary bitcoin
--   network)?
[_onTestNetwork] :: BitcoinInfo -> Bool

-- | The timestamp of the oldest key in the key pool.
[_keyPoolOldest] :: BitcoinInfo -> Integer

-- | The size of the key pool.
[_keyPoolSize] :: BitcoinInfo -> Integer

-- | How much do we currently pay as a transaction fee?
[_transactionFeePaid] :: BitcoinInfo -> Integer

-- | If the wallet is unlocked, the number of seconds until a re-lock is
--   needed.
[_unlockedUntil] :: BitcoinInfo -> Maybe Integer

-- | Any alerts will show up here. This should normally be an empty string.
[_bitcoindErrors] :: BitcoinInfo -> Text
walletVersion :: Lens' BitcoinInfo Integer
unlockedUntil :: Lens' BitcoinInfo (Maybe Integer)
transactionFeePaid :: Lens' BitcoinInfo Integer
proxy :: Lens' BitcoinInfo Text
protocolVersion :: Lens' BitcoinInfo Integer
onTestNetwork :: Lens' BitcoinInfo Bool
numConnections :: Lens' BitcoinInfo Integer
numBlocks :: Lens' BitcoinInfo Integer
keyPoolSize :: Lens' BitcoinInfo Integer
keyPoolOldest :: Lens' BitcoinInfo Integer
generationDifficulty :: Lens' BitcoinInfo Double
bitcoindErrors :: Lens' BitcoinInfo Text
bitcoinVersion :: Lens' BitcoinInfo Integer
balance :: Lens' BitcoinInfo Integer
getInfo :: Client -> IO BitcoinInfo
instance Data.Aeson.Types.FromJSON.FromJSON Network.Bitcoin.Api.Misc.BitcoinInfo
instance GHC.Show.Show Network.Bitcoin.Api.Misc.BitcoinInfo

module Network.Bitcoin.Api.Wallet

-- | Lists unspent transaction with default parameters
listUnspent :: Client -> IO [UnspentTransaction]

-- | Lists unspent transactions with configurable parameters
listUnspentWith :: Client -> Integer -> Integer -> IO [UnspentTransaction]

-- | Lists all accounts currently known by the wallet with default
--   parameters
listAccounts :: Client -> IO [(Account, Btc)]

-- | Lists all accounts currently known by the wallet with configurable
--   parameters
listAccountsWith :: Client -> Integer -> Bool -> IO [(Account, Btc)]

-- | Returns the amount of Btc currently held in the wallet by a specified
--   account.
getAccountBalance :: Client -> Account -> IO Btc

-- | 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 :: Client -> IO Address

-- | Provides access to a new receiving address filed under a specific
--   account. Intended to be published to another party that wishes to send
--   you money.
newAddressWith :: Client -> Account -> IO Address

-- | Provides access to a new change address, which will not appear in the
--   UI. This is to be used with raw transactions only.
newChangeAddress :: Client -> IO Address

-- | Provides access to the <a>Account</a> an <a>Address</a> belongs to.
getAddressAccount :: Client -> Address -> IO Account

module Network.Bitcoin.Api.Dump
getPrivateKey :: Client -> Address -> IO PrivateKey

module Network.Bitcoin.Api.Client

-- | Client session data
data Client
Client :: String -> Options -> Session -> Client

-- | The JSON RPC url
[clientUrl] :: Client -> String

-- | Default HTTP options to use with <tt>wreq</tt> requests
[clientOpts] :: Client -> Options

-- | Connection reuse of our HTTP session
[clientSession] :: Client -> Session

-- | Initializes a client and prepares it for making requests against the
--   Bitcoin RPC API. Connection reuse is provided, and cleanup of any
--   acquired resources is handled automatically.
withClient :: String -> Int -> Text -> Text -> (Client -> IO a) -> IO a

module Network.Bitcoin.Api.Blockchain

-- | Gets the amount of blocks currently in the blockchain, also known as
--   the <tt>height</tt> of the blockchain.
getBlockCount :: Client -> IO Integer

-- | Get the hash of a block based on its offset (height).
getBlockHash :: Client -> Integer -> IO BlockHash

-- | Gets a block based on its hash.
getBlock :: Client -> HexString -> IO Block

module Network.Bitcoin.Api.Mining

-- | Generate a certain amount of new blocks. Available in <tt>regtest</tt>
--   mode only.
generate :: Client -> Integer -> IO [Block]


-- | This module provides functionality to manipulate raw transaction. It
--   automatically interprets transactions using the `bitcoin-tx` package,
--   so you can work with actual <a>Transaction</a> objects rather than
--   their serialized format.
module Network.Bitcoin.Api.Transaction

-- | Creates a new transaction, but does not sign or submit it yet. You
--   provide a set of unspent transactions that you have the authority to
--   spend, and you provide a destination for all your bitcoins.
--   
--   <b>WARNING: Check your math!</b> If the sum of the Btc in unspent
--   transactions of your request is more than the sum of the Btc in the
--   destinations, this will be the miner's fee. It is reasonable to leave
--   a small amount for the miners, but if there is a large discrepancy
--   between input and output, there are no guarantees you will be warned.
--   
--   All this function does is create a default script on how to spend
--   coins from one or more inputs to one or more outputs. Checking and
--   verifying the transaction will only happen when you actually submit
--   the transaction to the network.
create :: Client -> [UnspentTransaction] -> [(Address, Btc)] -> IO Transaction

-- | Signs a raw transaction with configurable parameters.
sign :: Client -> Transaction -> Maybe [UnspentTransaction] -> Maybe [PrivateKey] -> IO (Transaction, Bool)

-- | Sends a transaction through the Bitcoin network
send :: Client -> Transaction -> IO TransactionId

-- | Returns a list of transactions that occured since a certain block
--   height. If no block height was provided, the genisis block with height
--   0 is assumed. The transactions returned are listed chronologically.
list :: Client -> Maybe Integer -> Maybe Integer -> IO [Transaction]
