-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An interface to bitcoind. -- -- This can be used to send Bitcoins, query balances, etc. It requires -- the Bitcoin daemon to be running and accessible via HTTP. -- --
--   import Network.Bitcoin
--   
--   main = do
--      balance <- getBalance auth
--      putStrLn $ show balance ++ " BTC"
--    where
--      auth = Auth "http://127.0.0.1:8332" "user" "password"
--   
-- -- To learn more about Bitcoin, see http://www.bitcoin.org. @package network-bitcoin @version 1.2.1 -- | Contains the common types used through bitcoin RPC calls, that aren't -- specific to a single submodule. module Network.Bitcoin.Types -- | Auth describes authentication credentials for making API -- requests to the Bitcoin daemon. data Auth Auth :: Text -> Text -> Text -> Auth -- | URL, with port, where bitcoind listens rpcUrl :: Auth -> Text -- | same as bitcoind's rpcuser config rpcUser :: Auth -> Text -- | same as bitcoind's rpcpassword config rpcPassword :: Auth -> Text -- | A BitcoinException is thrown when 'callApi encounters an error. -- The API error code is represented as an Int, the message as a -- String. -- -- It may also be thrown when the value returned by the bitcoin API -- wasn't what we expected. -- -- WARNING: Any of the functions in this module's public API may throw -- this exception. You should plan on handling it. data BitcoinException -- | A BitcoinApiError has an error code error message, as returned -- by bitcoind's JSON-RPC response. BitcoinApiError :: Int -> Text -> BitcoinException -- | The raw JSON returned, if we can't figure out what actually went -- wrong. BitcoinResultTypeError :: ByteString -> BitcoinException -- | A string returned by the bitcoind API, representing data as hex. -- -- What that data represents depends on the API call, but should be -- dcumented accordingly. type HexString = Text -- | A hexadecimal string representation of a 256-bit unsigned integer. -- -- This integer is a unique transaction identifier. type TransactionID = HexString -- | A satoshi is the smallest subdivision of bitcoins. For the resolution, -- use resolution from Fixed. data Satoshi Satoshi :: Satoshi -- | The type of bitcoin money, represented with a fixed-point number. type BTC = Fixed Satoshi -- | An account on the wallet is just a label to easily specify private -- keys. -- -- The default account is an empty string. type Account = Text -- | An address for sending or receiving money. type Address = HexString -- | I don't know what this is. A signature of some sort? If you know, -- please submit a patch documenting this properly! data ScriptSig ScriptSig :: HexString -> HexString -> ScriptSig sigAsm :: ScriptSig -> HexString sigHex :: ScriptSig -> HexString instance Typeable BitcoinException instance Show Auth instance Read Auth instance Ord Auth instance Eq Auth instance Show BitcoinException instance Read BitcoinException instance Ord BitcoinException instance Eq BitcoinException instance Show ScriptSig instance Read ScriptSig instance Ord ScriptSig instance Eq ScriptSig instance FromJSON ScriptSig instance HasResolution Satoshi instance Exception BitcoinException -- | The API exposed in this module should be considered unstable, and is -- subject to change between minor revisions. -- -- If the version number is a.b.c.d, and either a or b changes, then the -- module's whole API may have changed (if only b changes, then it was -- probably a minor change). -- -- If c changed, then only the internal API may change. The rest of the -- module is guaranteed to be stable. -- -- If only d changes, then there were no user-facing code changes made. module Network.Bitcoin.Internal -- | A space efficient, packed, unboxed Unicode text type. data Text :: * -- | Boxed vectors, supporting efficient slicing. data Vector a :: * -> * -- | A type that can be converted from JSON, with the possibility of -- failure. -- -- When writing an instance, use empty, mzero, or -- fail to make a conversion fail, e.g. if an Object is -- missing a required key, or the value is of the wrong type. -- -- An example type and instance: -- --
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord { x :: Double, y :: Double }
--   
--   instance FromJSON Coord where
--      parseJSON (Object v) = Coord    <$>
--                             v .: "x" <*>
--                             v .: "y"
--   
--   -- A non-Object value is of the wrong type, so use mzero to fail.
--      parseJSON _          = mzero
--   
-- -- Note the use of the OverloadedStrings language extension -- which enables Text values to be written as string literals. -- -- Instead of manually writing your FromJSON instance, there are -- three options to do it automatically: -- -- -- -- To use this, simply add a deriving Generic clause to -- your datatype and declare a FromJSON instance for your -- datatype without giving a definition for parseJSON. -- -- For example the previous example can be simplified to just: -- --
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import GHC.Generics
--   
--   data Coord { x :: Double, y :: Double } deriving Generic
--   
--   instance FromJSON Coord
--   
class FromJSON a parseJSON :: FromJSON a => Value -> Parser a -- | callApi is a low-level interface for making authenticated API -- calls to a Bitcoin daemon. The first argument specifies authentication -- details (URL, username, password) and is often curried for -- convenience: -- --
--   callBtc = callApi $ Auth "http://127.0.0.1:8332" "user" "password"
--   
-- -- The second argument is the command name. The third argument provides -- parameters for the API call. -- --
--   let result = callBtc "getbalance" [ tj "account-name", tj 6 ]
--   
-- -- On error, throws a BitcoinException. callApi :: FromJSON v => Auth -> Text -> [Value] -> IO v -- | The no conversion needed implementation of callApi. THis lets -- us inline and specialize callApi for its parameters, while keeping the -- bulk of the work in this function shared. callApi' :: Auth -> ByteString -> IO ByteString -- | Used to allow null to decode to a tuple. data Nil Nil :: () -> Nil unNil :: Nil -> () -- | A handy shortcut for toJSON, because I'm lazy. tj :: ToJSON a => a -> Value -- | A wrapper for a vector of address:amount pairs. The RPC expects that -- as an object of address:amount pairs, instead of a -- vector. So that's what we give them with AddrAddress's ToJSON. newtype AddrAddress AA :: (Vector (Address, BTC)) -> AddrAddress instance Show BitcoinRpcError instance Read BitcoinRpcError instance Ord BitcoinRpcError instance Eq BitcoinRpcError instance Show a => Show (BitcoinRpcResponse a) instance Read a => Read (BitcoinRpcResponse a) instance Ord a => Ord (BitcoinRpcResponse a) instance Eq a => Eq (BitcoinRpcResponse a) instance ToJSON AddrAddress instance FromJSON Nil instance FromJSON a => FromJSON (BitcoinRpcResponse a) instance FromJSON BitcoinRpcError -- | An interface to bitcoind's available block-chain-related RPC calls. -- The implementation of these functions can be found at -- https://github.com/bitcoin/bitcoin/blob/master/src/rpcblockchain.cpp. -- -- If any APIs are missing, patches are always welcome. If you look at -- the source of this module, you'll see that the interface code is -- trivial. module Network.Bitcoin.BlockChain -- | Auth describes authentication credentials for making API -- requests to the Bitcoin daemon. data Auth Auth :: Text -> Text -> Text -> Auth -- | URL, with port, where bitcoind listens rpcUrl :: Auth -> Text -- | same as bitcoind's rpcuser config rpcUser :: Auth -> Text -- | same as bitcoind's rpcpassword config rpcPassword :: Auth -> Text -- | A hexadecimal string representation of a 256-bit unsigned integer. -- -- This integer is a unique transaction identifier. type TransactionID = HexString -- | The type of bitcoin money, represented with a fixed-point number. type BTC = Fixed Satoshi -- | I don't know what this is. A signature of some sort? If you know, -- please submit a patch documenting this properly! data ScriptSig ScriptSig :: HexString -> HexString -> ScriptSig sigAsm :: ScriptSig -> HexString sigHex :: ScriptSig -> HexString -- | Returns the number of blocks in the longest block chain. getBlockCount :: Auth -> IO Integer -- | Returns the proof-of-work difficulty as a multiple of the minimum -- difficulty. getDifficulty :: Auth -> IO Integer -- | Sets the transaction fee will will pay to the network. Values of 0 are -- rejected. setTransactionFee :: Auth -> BTC -> IO () -- | Returns all transaction identifiers in the memory pool. getRawMemoryPool :: Auth -> IO (Vector TransactionID) -- | The hash of a given block. type BlockHash = HexString -- | Returns the hash of the block in best-block-chain at the given index. getBlockHash :: Auth -> Integer -> IO BlockHash -- | Information about a given block in the block chain. data Block Block :: BlockHash -> Integer -> Integer -> Integer -> Integer -> BlockHash -> Vector TransactionID -> Integer -> Integer -> HexString -> Integer -> Maybe BlockHash -> Maybe BlockHash -> Block blockHash :: Block -> BlockHash -- | The number of confirmations the block has. blkConfirmations :: Block -> Integer -- | The size of the block. blkSize :: Block -> Integer -- | The height of the block. TODO: Clarify this. blkHeight :: Block -> Integer -- | The version of the block. blkVersion :: Block -> Integer -- | The hash of the block at the root of the merkle tree which this block -- belongs to. merkleRoot :: Block -> BlockHash -- | Should this be a transaction, or transaction id? subTransactions :: Block -> Vector TransactionID -- | The time it was mined. blkTime :: Block -> Integer -- | The block's nonce. blkNonce :: Block -> Integer blkBits :: Block -> HexString -- | How hard was this block to mine? blkDifficulty :: Block -> Integer -- | A pointer to the next block in the chain. nextBlock :: Block -> Maybe BlockHash -- | A pointer to the previous block in the chain. prevBlock :: Block -> Maybe BlockHash -- | Returns details of a block with given block-hash. getBlock :: Auth -> BlockHash -> IO Block -- | Information on the unspent transaction in the output set. data OutputSetInfo OutputSetInfo :: BlockHash -> Integer -> Integer -> Integer -> OutputSetInfo osiBestBlock :: OutputSetInfo -> BlockHash -- | The number of transactions in the output set. numTransactions :: OutputSetInfo -> Integer -- | The number of outputs for the transactions. transactionOutputs :: OutputSetInfo -> Integer -- | The serialized size of the output set. serializedSize :: OutputSetInfo -> Integer -- | Returns statistics about the unspent transaction output set. getOutputSetInfo :: Auth -> IO OutputSetInfo -- | Details about an unspent transaction output. data OutputInfo OutputInfo :: BlockHash -> Integer -> BTC -> ScriptSig -> Integer -> Bool -> OutputInfo oiBestBlock :: OutputInfo -> BlockHash -- | The number of times this transaction has been confirmed. oiConfirmations :: OutputInfo -> Integer -- | The amount transferred. oiAmount :: OutputInfo -> BTC -- | The public key of the sender. oiScriptPubKey :: OutputInfo -> ScriptSig -- | The version of this transaction. oiVersion :: OutputInfo -> Integer -- | Is this transaction part of the coin base? oiCoinBase :: OutputInfo -> Bool -- | Returns details about an unspent transaction output. getOutputInfo :: Auth -> TransactionID -> Integer -> IO OutputInfo instance Show Block instance Read Block instance Ord Block instance Eq Block instance Show OutputSetInfo instance Read OutputSetInfo instance Ord OutputSetInfo instance Eq OutputSetInfo instance Show OutputInfo instance Read OutputInfo instance Ord OutputInfo instance Eq OutputInfo instance FromJSON OutputInfo instance FromJSON OutputSetInfo instance FromJSON Block -- | An interface to bitcoind's available private key calls. The -- implementation of these functions can be found at -- https://github.com/bitcoin/bitcoin/blob/master/src/rpcdump.cpp. -- -- If any APIs are missing, patches are always welcome. If you look at -- the source of this module, you'll see that the interface code is -- trivial. module Network.Bitcoin.Dump -- | A textual representation of a bitcoin private key. type PrivateKey = Text -- | Adds a private key (as returned by dumpprivkey) to your wallet. importPrivateKey :: Auth -> PrivateKey -> Maybe Account -> IO () -- | Reveals the private key corresponding to the given address. dumpPrivateKey :: Auth -> Address -> IO PrivateKey -- | An interface to bitcoind's available mining RPC calls. The -- implementation of these functions can be found at -- https://github.com/bitcoin/bitcoin/blob/master/src/rpcmining.cpp. -- -- If any APIs are missing, patches are always welcome. If you look at -- the source of this module, you'll see that the interface code is -- trivial. -- -- Note that it is highly discouraged to use bitcoind for actual bitcoin -- mining. It uses the CPU for mining, which is much, much less power -- efficient than GPU mining. If you're paying for power, you will not -- come out ahead. -- -- Instead, consider using a GPU miner listed at -- https://en.bitcoin.it/wiki/Software#Mining_apps. module Network.Bitcoin.Mining -- | Auth describes authentication credentials for making API -- requests to the Bitcoin daemon. data Auth Auth :: Text -> Text -> Text -> Auth -- | URL, with port, where bitcoind listens rpcUrl :: Auth -> Text -- | same as bitcoind's rpcuser config rpcUser :: Auth -> Text -- | same as bitcoind's rpcpassword config rpcPassword :: Auth -> Text -- | Returns whether or not bitcoind is generating bitcoins. getGenerate :: Auth -> IO Bool -- | Controls whether or not bitcoind is generating bitcoins. setGenerate :: Auth -> Bool -> Maybe Int -> IO () -- | Returns a recent hashes per second performance measurement while -- generating. getHashesPerSec :: Auth -> IO Integer -- | Information related to the current bitcoind mining operation. -- -- If a field is undocumented here, it's because I don't know what it -- means. If you DO know what it means, I'd love it if you would submit a -- patch to help complete this documentation. data MiningInfo MiningInfo :: Integer -> Integer -> Integer -> Double -> Text -> Bool -> Integer -> Integer -> Integer -> Bool -> MiningInfo -- | The number of blocks in our block-chain. nBlocks :: MiningInfo -> Integer -- | The size of the current block we're mining. currentBlockSize :: MiningInfo -> Integer currentBlockTransaction :: MiningInfo -> Integer -- | How difficult mining currently is. difficulty :: MiningInfo -> Double -- | Any mining errors that may have come up. miningErrors :: MiningInfo -> Text -- | Are we currently generating bitcoins? isGenerating :: MiningInfo -> Bool -- | How many processors have we limited bitcoin mining to? generationProcessorLimit :: MiningInfo -> Integer -- | How fast is the mining going? hashesPerSecond :: MiningInfo -> Integer pooledTransactions :: MiningInfo -> Integer -- | Are we on the bitcoin test network (as opposed to the real thing)? miningOnTestNetwork :: MiningInfo -> Bool -- | Returns an object containing mining-related information. getMiningInfo :: Auth -> IO MiningInfo -- | The hash data returned from getWork. data HashData HashData :: HexString -> HexString -> HexString -> HexString -> HashData blockData :: HashData -> HexString -- | Little-endian hash target, formatted as a hexadecimal string. hdTarget :: HashData -> HexString hash1 :: HashData -> HexString midstate :: HashData -> HexString -- | Returns formatted hash data to work on. getWork :: Auth -> IO HashData -- | Tries to solve the given block, and returns true if it was successful. solveBlock :: Auth -> HexString -> IO Bool -- | A transaction to be included in the next block. data Transaction Transaction :: HexString -> HexString -> Vector Integer -> Maybe Integer -> Integer -> Transaction txnData :: Transaction -> HexString txnHash :: Transaction -> HexString depends :: Transaction -> Vector Integer txnFee :: Transaction -> Maybe Integer sigOps :: Transaction -> Integer data CoinBaseAux CoinBaseAux :: HexString -> CoinBaseAux cbFlags :: CoinBaseAux -> HexString -- | A template for constructing a block to work on. -- -- See https://en.bitcoin.it/wiki/BIP_0022 for the full -- specification. data BlockTemplate BlockTemplate :: Integer -> HexString -> Vector Transaction -> CoinBaseAux -> Integer -> HexString -> Integer -> HexString -> Integer -> Integer -> Integer -> HexString -> Integer -> BlockTemplate blockVersion :: BlockTemplate -> Integer -- | Hash of current highest block. previousBlockHash :: BlockTemplate -> HexString -- | Contents of non-coinbase transactions that should be included in the -- next block. transactionsToInclude :: BlockTemplate -> Vector Transaction -- | Data that should be included in coinbase. coinBaseAux :: BlockTemplate -> CoinBaseAux -- | Maximum allowable input to coinbase transaction, including the -- generation award and transaction fees. coinBaseValue :: BlockTemplate -> Integer -- | Hash target. btTarget :: BlockTemplate -> HexString -- | Minimum timestamp appropriate for next block. minTime :: BlockTemplate -> Integer -- | Range of valid nonces. nonceRange :: BlockTemplate -> HexString -- | Limit of sigops in blocks. sigopLimit :: BlockTemplate -> Integer -- | Limit of block size. sizeLimit :: BlockTemplate -> Integer -- | Current timestamp. curTime :: BlockTemplate -> Integer -- | Compressed target of the next block. btBits :: BlockTemplate -> HexString -- | Height of the next block. btHeight :: BlockTemplate -> Integer -- | Returns data needed to construct a block to work on. getBlockTemplate :: Auth -> IO BlockTemplate -- | Attempts to submit a new block to the network. submitBlock :: Auth -> HexString -> IO Bool instance Show MiningInfo instance Read MiningInfo instance Ord MiningInfo instance Eq MiningInfo instance Show HashData instance Read HashData instance Ord HashData instance Eq HashData instance Show Transaction instance Read Transaction instance Ord Transaction instance Eq Transaction instance Show CoinBaseAux instance Read CoinBaseAux instance Ord CoinBaseAux instance Eq CoinBaseAux instance Show BlockTemplate instance Read BlockTemplate instance Ord BlockTemplate instance Eq BlockTemplate instance FromJSON StupidReturnValue instance FromJSON BlockTemplate instance FromJSON CoinBaseAux instance FromJSON Transaction instance ToJSON HashData instance FromJSON HashData instance FromJSON MiningInfo -- | An interface to bitcoind's available network-related RPC calls. The -- implementation of these functions can be found at -- https://github.com/bitcoin/bitcoin/blob/master/src/rpcnet.cpp. -- -- If any APIs are missing, patches are always welcome. If you look at -- the source of this module, you'll see that the interface code is -- trivial. module Network.Bitcoin.Net -- | Auth describes authentication credentials for making API -- requests to the Bitcoin daemon. data Auth Auth :: Text -> Text -> Text -> Auth -- | URL, with port, where bitcoind listens rpcUrl :: Auth -> Text -- | same as bitcoind's rpcuser config rpcUser :: Auth -> Text -- | same as bitcoind's rpcpassword config rpcPassword :: Auth -> Text -- | Returns the number of connections to other nodes. getConnectionCount :: Auth -> IO Integer -- | Information about a peer node of the Bitcoin network. -- -- The documentation for this data structure is incomplete, as I honestly -- don't know what some of these fields are for. Patches are welcome! data PeerInfo PeerInfo :: Text -> Text -> Integer -> Integer -> Integer -> Integer -> Text -> Bool -> Integer -> Integer -> Integer -> PeerInfo -- | The IP:port of this peer, as a string. addressName :: PeerInfo -> Text services :: PeerInfo -> Text -- | Relative to the first time we conected with this peer (and in -- milliseconds), the last time we sent this peer any data. lastSend :: PeerInfo -> Integer -- | Relative to the first time we connected with this peer (and in -- milliseconds), the last time we sent this peer any data. lastRecv :: PeerInfo -> Integer -- | How long have we been connected to this peer (in milliseconds). connectionTime :: PeerInfo -> Integer -- | The version of the Bitcion client the peer is running. peerVersion :: PeerInfo -> Integer -- | The sub-version of the Bitcoin client the peer is running. peerSubversion :: PeerInfo -> Text inbound :: PeerInfo -> Bool releaseTime :: PeerInfo -> Integer startingHeight :: PeerInfo -> Integer -- | How many times has this peer behaved badly? banScore :: PeerInfo -> Integer -- | Returns data about all connected peer nodes. getPeerInfo :: Auth -> IO [PeerInfo] instance Show PeerInfo instance Read PeerInfo instance Ord PeerInfo instance Eq PeerInfo instance FromJSON PeerInfo -- | An interface to bitcoind's available raw transaction-related RPC -- calls. The implementation of these functions can be found at -- https://github.com/bitcoin/bitcoin/blob/master/src/rpcrawtransaction.cpp. -- -- If any APIs are missing, patches are always welcome. If you look at -- the source of this module, you'll see that the interface code is -- trivial. -- -- Also, documentation for this module is scarce. I would love the -- addition of more documentation by anyone who knows what these things -- are. module Network.Bitcoin.RawTransaction -- | Auth describes authentication credentials for making API -- requests to the Bitcoin daemon. data Auth Auth :: Text -> Text -> Text -> Auth -- | URL, with port, where bitcoind listens rpcUrl :: Auth -> Text -- | same as bitcoind's rpcuser config rpcUser :: Auth -> Text -- | same as bitcoind's rpcpassword config rpcPassword :: Auth -> Text -- | I don't know what this is. A signature of some sort? If you know, -- please submit a patch documenting this properly! data ScriptSig ScriptSig :: HexString -> HexString -> ScriptSig sigAsm :: ScriptSig -> HexString sigHex :: ScriptSig -> HexString -- | Just like most binary data retrieved from bitcoind, a raw transaction -- is represented by a hexstring. -- -- This is a serialized, hex-encoded transaction. type RawTransaction = HexString -- | Get a raw transaction from its unique ID. getRawTransaction :: Auth -> TransactionID -> IO RawTransaction -- | A transaction into an account. This can either be a coinbase -- transaction, or a standard transaction with another account. data TxIn TxCoinbase :: HexString -> TxIn txCoinbase :: TxIn -> HexString TxIn :: TransactionID -> Integer -> ScriptSig -> Integer -> TxIn -- | This transaction's ID. txInId :: TxIn -> TransactionID numOut :: TxIn -> Integer scriptSig :: TxIn -> ScriptSig -- | A transaction sequence number. txSequence :: TxIn -> Integer -- | The type of a transaction out. -- -- More documentation is needed here. Submit a patch if you know what -- this is about! data TxnOutputType -- | JSON of pubkey received. TxnPubKey :: TxnOutputType -- | JSON of pubkeyhash received. TxnPubKeyHash :: TxnOutputType -- | JSON of scripthash received. TxnScriptHash :: TxnOutputType -- | JSON of multisig received. TxnMultisig :: TxnOutputType -- | A public key of someone we sent money to. data ScriptPubKey NonStandardScriptPubKey :: HexString -> HexString -> ScriptPubKey -- | The JSON asm field. nspkAsm :: ScriptPubKey -> HexString -- | The JSON hex field. nspkHex :: ScriptPubKey -> HexString StandardScriptPubKey :: HexString -> HexString -> Integer -> TxnOutputType -> Vector Address -> ScriptPubKey -- | The JSON asm field. sspkAsm :: ScriptPubKey -> HexString -- | The JSON hex field. sspkHex :: ScriptPubKey -> HexString -- | The number of required signatures. requiredSigs :: ScriptPubKey -> Integer -- | The type of the transaction. sspkType :: ScriptPubKey -> TxnOutputType -- | The addresses associated with this key. sspkAddresses :: ScriptPubKey -> Vector Address -- | A transaction out of an account. data TxOut TxOut :: BTC -> ScriptPubKey -> TxOut -- | The amount of bitcoin transferred out. txoutVal :: TxOut -> BTC -- | The public key of the account we sent the money to. scriptPubKey :: TxOut -> ScriptPubKey -- | Information on a single block. data BlockInfo ConfirmedBlock :: Integer -> Integer -> Integer -> BlockInfo -- | The number of confirmations a block has. This will always be >= 1. confirmations :: BlockInfo -> Integer cbTime :: BlockInfo -> Integer -- | The JSON blocktime field. blockTime :: BlockInfo -> Integer -- | An unconfirmed block is boring, but a possibility. UnconfirmedBlock :: BlockInfo -- | The raw transaction info for a given transaction ID. data RawTransactionInfo RawTransactionInfo :: RawTransaction -> Integer -> Integer -> Vector TxIn -> Vector TxOut -> HexString -> BlockInfo -> RawTransactionInfo -- | The raw transaction. raw :: RawTransactionInfo -> RawTransaction -- | The transaction version number. txnVersion :: RawTransactionInfo -> Integer txnLockTime :: RawTransactionInfo -> Integer -- | The vector of transactions in. vin :: RawTransactionInfo -> Vector TxIn -- | The vector of transactions out. vout :: RawTransactionInfo -> Vector TxOut -- | The hash of the block that was used for this transaction. rawTxBlockHash :: RawTransactionInfo -> HexString -- | The transaction's block's info. rawBlockInfo :: RawTransactionInfo -> BlockInfo -- | Get raw transaction info for a given transaction ID. The data -- structure returned is quite sprawling and undocumented, so any patches -- to help simplify things would be greatly appreciated. getRawTransactionInfo :: Auth -> TransactionID -> IO RawTransactionInfo data UnspentTransaction UnspentTransaction :: TransactionID -> Integer -> HexString -> Maybe HexString -> BTC -> Integer -> UnspentTransaction unspentTransactionId :: UnspentTransaction -> TransactionID outIdx :: UnspentTransaction -> Integer unspentScriptPubKey :: UnspentTransaction -> HexString redeemScript :: UnspentTransaction -> Maybe HexString unspentAmount :: UnspentTransaction -> BTC usConfirmations :: UnspentTransaction -> Integer -- | Returns an array of unspent transaction outputs with between minconf -- and maxconf (inclusive) confirmations. If addresses are given, the -- result will be filtered to include only those addresses. listUnspent :: Auth -> Maybe Int -> Maybe Int -> Vector Address -> IO (Vector UnspentTransaction) -- | Create a transaction spending given inputs, sending to given -- addresses. -- -- Note that the transaction's inputs are not signed, and it is not -- stored in the wallet or transmitted to the network. -- -- Also, there is no checking to see if it's possible to send that much -- to the targets specified. In the future, such a scenario might throw -- an exception. createRawTransaction :: Auth -> Vector UnspentTransaction -> Vector (Address, BTC) -> IO HexString -- | A successfully decoded raw transaction, from a given serialized, -- hex-encoded transaction. data DecodedRawTransaction DecodedRawTransaction :: RawTransaction -> Integer -> Integer -> Vector TxIn -> Vector TxOut -> DecodedRawTransaction -- | The raw transaction. decRaw :: DecodedRawTransaction -> RawTransaction -- | The transaction version number. decTxnVersion :: DecodedRawTransaction -> Integer decTxnLockTime :: DecodedRawTransaction -> Integer -- | The vector of transactions in. decVin :: DecodedRawTransaction -> Vector TxIn -- | The vector of transactions out. decVout :: DecodedRawTransaction -> Vector TxOut -- | Decodes a raw transaction into a more accessible data structure. decodeRawTransaction :: Auth -> RawTransaction -> IO DecodedRawTransaction -- | Who can pay for a given transaction. data WhoCanPay All :: WhoCanPay AllOrAnyoneCanPay :: WhoCanPay None :: WhoCanPay NoneOrAnyoneCanPay :: WhoCanPay Single :: WhoCanPay SingleOrAnyoneCanPay :: WhoCanPay -- | A raw signed transaction contains the raw, signed hexstring and -- whether or not this transaction has a complete signature set. data RawSignedTransaction RawSignedTransaction :: HexString -> Bool -> RawSignedTransaction rawSigned :: RawSignedTransaction -> HexString hasCompleteSigSet :: RawSignedTransaction -> Bool -- | Sign inputs for a raw transaction. signRawTransaction :: Auth -> RawTransaction -> Maybe (Vector UnspentTransaction) -> Maybe (Vector HexString) -> Maybe WhoCanPay -> IO RawSignedTransaction sendRawTransaction :: Auth -> RawTransaction -> IO TransactionID instance Show TxIn instance Read TxIn instance Ord TxIn instance Eq TxIn instance Show TxnOutputType instance Read TxnOutputType instance Ord TxnOutputType instance Eq TxnOutputType instance Show ScriptPubKey instance Read ScriptPubKey instance Ord ScriptPubKey instance Eq ScriptPubKey instance Show TxOut instance Read TxOut instance Ord TxOut instance Eq TxOut instance Show BlockInfo instance Read BlockInfo instance Ord BlockInfo instance Eq BlockInfo instance Show RawTransactionInfo instance Read RawTransactionInfo instance Ord RawTransactionInfo instance Eq RawTransactionInfo instance FromJSON RawSignedTransaction instance ToJSON UnspentForSigning instance FromJSON DecodedRawTransaction instance ToJSON UnspentTransaction instance FromJSON UnspentTransaction instance FromJSON RawTransactionInfo instance FromJSON BlockInfo instance FromJSON TxOut instance FromJSON ScriptPubKey instance FromJSON TxnOutputType instance FromJSON TxIn -- | An interface to bitcoind's available wallet-related RPC calls. The -- implementation of these functions can be found at -- https://github.com/bitcoin/bitcoin/blob/master/src/rpcwallet.cpp. -- -- If any APIs are missing, patches are always welcome. If you look at -- the source of this module, you'll see that the interface code is -- trivial. -- -- Certain APIs were too complicated for me to write an interface for. If -- you figure them out, then patches are always welcome! They're left in -- the source as comments. module Network.Bitcoin.Wallet -- | Auth describes authentication credentials for making API -- requests to the Bitcoin daemon. data Auth Auth :: Text -> Text -> Text -> Auth -- | URL, with port, where bitcoind listens rpcUrl :: Auth -> Text -- | same as bitcoind's rpcuser config rpcUser :: Auth -> Text -- | same as bitcoind's rpcpassword config rpcPassword :: Auth -> Text -- | A plethora of information about a bitcoind instance. data BitcoindInfo BitcoindInfo :: Integer -> Integer -> Integer -> BTC -> Integer -> Integer -> Text -> Double -> Bool -> Integer -> Integer -> BTC -> Maybe Integer -> Text -> BitcoindInfo -- | What version of bitcoind are we running? bitcoinVersion :: BitcoindInfo -> Integer -- | What is bitcoind's current protocol number? protocolVersion :: BitcoindInfo -> Integer -- | What version is the wallet? walletVersion :: BitcoindInfo -> Integer -- | How much money is currently in the wallet? balance :: BitcoindInfo -> BTC -- | The number of blocks in our chain. numBlocks :: BitcoindInfo -> Integer -- | How many peers are we connected to? numConnections :: BitcoindInfo -> Integer -- | A blank string if we're not using a proxy. proxy :: BitcoindInfo -> Text -- | The difficulty multiplier for bitcoin mining operations. generationDifficulty :: BitcoindInfo -> Double -- | Are we on the test network (as opposed to the primary bitcoin -- network)? onTestNetwork :: BitcoindInfo -> Bool -- | The timestamp of the oldest key in the key pool. keyPoolOldest :: BitcoindInfo -> Integer -- | The size of the key pool. keyPoolSize :: BitcoindInfo -> Integer -- | How much do we currently pay as a transaction fee? transactionFeePaid :: BitcoindInfo -> BTC -- | If the wallet is unlocked, the number of seconds until a re-lock is -- needed. unlockedUntil :: BitcoindInfo -> Maybe Integer -- | Any alerts will show up here. This should normally be an empty string. bitcoindErrors :: BitcoindInfo -> Text -- | Returns an object containing various state info. getBitcoindInfo :: Auth -> IO BitcoindInfo -- | Returns a new bitcoin address for receiving payments. -- -- If an account is specified (recommended), the new address is added to -- the address book so payments received with the address will be -- credited to the given account. -- -- If no account is specified, the address will be credited to the -- account whose name is the empty string. i.e. the default account. getNewAddress :: Auth -> Maybe Account -> IO Address -- | Returns the current Bitcoin address for receiving payments to the -- given account. getAccountAddress :: Auth -> Account -> IO Address -- | Returns the account associated with the given address. getAccount :: Auth -> Address -> IO Account -- | Sets the account associated with the given address. setAccount :: Auth -> Address -> Account -> IO () -- | Returns the list of addresses for the given address. getAddressesByAccount :: Auth -> Account -> IO (Vector Address) -- | Sends some bitcoins to an address. sendToAddress :: Auth -> Address -> BTC -> Maybe Text -> Maybe Text -> IO TransactionID -- | Information on a given address. data AddressInfo AddressInfo :: Address -> BTC -> Maybe Account -> AddressInfo -- | The address in question. aiAddress :: AddressInfo -> Address -- | The address' balance. aiAmount :: AddressInfo -> BTC -- | The address' linked account. aiAccount :: AddressInfo -> Maybe Account -- | Lists groups of addresses which have had their common ownership made -- public by common use as inputs or as the resulting change in past -- transactions. listAddressGroupings :: Auth -> IO (Vector (Vector AddressInfo)) -- | A signature is a base-64 encoded string. type Signature = HexString -- | Sign a message with the private key of an address. signMessage :: Auth -> Address -> Text -> IO Signature -- | Verifies a signed message. verifyMessage :: Auth -> Address -> Signature -> Text -> IO Bool -- | Returns the total amount received by the given address with at least -- one confirmation. getReceivedByAddress :: Auth -> Address -> IO BTC -- | Returns the total amount received by the given address, with at least -- the give number of confirmations. getReceivedByAddress' :: Auth -> Address -> Int -> IO BTC -- | Returns the total amount received by address with the given account. getReceivedByAccount :: Auth -> Account -> IO BTC -- | Returns the total amount received by addresses with the given account, -- counting only transactions with the given minimum number of -- confirmations. getReceivedByAccount' :: Auth -> Account -> Int -> IO BTC -- | Returns the server's total available balance. getBalance :: Auth -> IO BTC -- | Returns the balance in the given account, counting only transactions -- with at least one confirmation. getBalance' :: Auth -> Account -> IO BTC -- | Returns the balance in the given account, counting only transactions -- with at least the given number of confirmations. getBalance'' :: Auth -> Account -> Int -> IO BTC -- | Move bitcoins from one account in your wallet to another. -- -- If you want to send bitcoins to an address not in your wallet, use -- sendFromAccount. moveBitcoins :: Auth -> Account -> Account -> BTC -> Text -> IO () -- | Sends bitcoins from a given account in our wallet to a given address. -- -- A transaction and sender comment may be optionally provided. sendFromAccount :: Auth -> Account -> Address -> BTC -> Maybe Text -> Maybe Text -> IO TransactionID -- | Send to a whole bunch of address at once. sendMany :: Auth -> Account -> Vector (Address, BTC) -> Maybe Text -> IO TransactionID -- | Information on how much was received by a given address. data ReceivedByAddress ReceivedByAddress :: Address -> Account -> BTC -> Integer -> ReceivedByAddress -- | The address which the money was deposited to. recvAddress :: ReceivedByAddress -> Address -- | The account which this address belongs to. recvAccount :: ReceivedByAddress -> Account -- | The amount received. recvAmount :: ReceivedByAddress -> BTC -- | The number of confirmations of the most recent included transaction. recvNumConfirmations :: ReceivedByAddress -> Integer -- | Lists the amount received by each address which has received money at -- some point, counting only transactions with at least one confirmation. listReceivedByAddress :: Auth -> IO (Vector ReceivedByAddress) -- | List the amount received by each of our addresses, counting only -- transactions with the given minimum number of confirmations. listReceivedByAddress' :: Auth -> Int -> Bool -> IO (Vector ReceivedByAddress) data ReceivedByAccount ReceivedByAccount :: Account -> BTC -> Integer -> ReceivedByAccount -- | The account we received into. raccAccount :: ReceivedByAccount -> Account -- | The mount received. ^ The number of confirmations of the most recent -- included transaction. raccAmount :: ReceivedByAccount -> BTC raccNumConfirmations :: ReceivedByAccount -> Integer -- | Lists the amount received by each account which has received money at -- some point, counting only transactions with at leaset one -- confirmation. listReceivedByAccount :: Auth -> IO (Vector ReceivedByAccount) -- | List the amount received by each of our accounts, counting only -- transactions with the given minimum number of confirmations. listReceivedByAccount' :: Auth -> Int -> Bool -> IO (Vector ReceivedByAccount) -- | Safely copies wallet.dat to the given destination, which can be either -- a directory, or a path with filename. backupWallet :: Auth -> FilePath -> IO () -- | Fills the keypool. keyPoolRefill :: Auth -> IO () -- | Stores the wallet decryption key in memory for the given amount of -- time. unlockWallet :: Auth -> Text -> Integer -> IO () -- | Removes the wallet encryption key from memory, locking the wallet. -- -- After calling this function, you will need to call unlockWallet -- again before being able to call methods which require the wallet to be -- unlocked. -- -- Note: In future releases, we might introduce an unlocked monad, -- so locking and unlocking is automatic. lockWallet :: Auth -> IO () -- | Changes the wallet passphrase. changePassword :: Auth -> Text -> Text -> IO () -- | Encrypts the wallet with the given passphrase. -- -- WARNING: bitcoind will shut down after calling this method. Don't say -- I didn't warn you. encryptWallet :: Auth -> Text -> IO () -- | Checks if a given address is a valid one. isAddressValid :: Auth -> Address -> IO Bool instance Show BitcoindInfo instance Read BitcoindInfo instance Ord BitcoindInfo instance Eq BitcoindInfo instance Show AddressInfo instance Read AddressInfo instance Eq AddressInfo instance Ord AddressInfo instance Show ReceivedByAddress instance Read ReceivedByAddress instance Ord ReceivedByAddress instance Eq ReceivedByAddress instance Show ReceivedByAccount instance Read ReceivedByAccount instance Ord ReceivedByAccount instance Eq ReceivedByAccount instance FromJSON IsValid instance FromJSON ReceivedByAccount instance FromJSON ReceivedByAddress instance FromJSON AddressInfo instance FromJSON BitcoindInfo -- | A Haskell binding to the bitcoind server. module Network.Bitcoin -- | Auth describes authentication credentials for making API -- requests to the Bitcoin daemon. data Auth Auth :: Text -> Text -> Text -> Auth -- | URL, with port, where bitcoind listens rpcUrl :: Auth -> Text -- | same as bitcoind's rpcuser config rpcUser :: Auth -> Text -- | same as bitcoind's rpcpassword config rpcPassword :: Auth -> Text -- | A BitcoinException is thrown when 'callApi encounters an error. -- The API error code is represented as an Int, the message as a -- String. -- -- It may also be thrown when the value returned by the bitcoin API -- wasn't what we expected. -- -- WARNING: Any of the functions in this module's public API may throw -- this exception. You should plan on handling it. data BitcoinException -- | A BitcoinApiError has an error code error message, as returned -- by bitcoind's JSON-RPC response. BitcoinApiError :: Int -> Text -> BitcoinException -- | The raw JSON returned, if we can't figure out what actually went -- wrong. BitcoinResultTypeError :: ByteString -> BitcoinException -- | A string returned by the bitcoind API, representing data as hex. -- -- What that data represents depends on the API call, but should be -- dcumented accordingly. type HexString = Text -- | A hexadecimal string representation of a 256-bit unsigned integer. -- -- This integer is a unique transaction identifier. type TransactionID = HexString -- | A satoshi is the smallest subdivision of bitcoins. For the resolution, -- use resolution from Fixed. data Satoshi Satoshi :: Satoshi -- | The type of bitcoin money, represented with a fixed-point number. type BTC = Fixed Satoshi -- | An account on the wallet is just a label to easily specify private -- keys. -- -- The default account is an empty string. type Account = Text -- | An address for sending or receiving money. type Address = HexString -- | I don't know what this is. A signature of some sort? If you know, -- please submit a patch documenting this properly! data ScriptSig -- | Returns the number of blocks in the longest block chain. getBlockCount :: Auth -> IO Integer -- | Returns the proof-of-work difficulty as a multiple of the minimum -- difficulty. getDifficulty :: Auth -> IO Integer -- | Sets the transaction fee will will pay to the network. Values of 0 are -- rejected. setTransactionFee :: Auth -> BTC -> IO () -- | Returns all transaction identifiers in the memory pool. getRawMemoryPool :: Auth -> IO (Vector TransactionID) -- | The hash of a given block. type BlockHash = HexString -- | Returns the hash of the block in best-block-chain at the given index. getBlockHash :: Auth -> Integer -> IO BlockHash -- | Information about a given block in the block chain. data Block Block :: BlockHash -> Integer -> Integer -> Integer -> Integer -> BlockHash -> Vector TransactionID -> Integer -> Integer -> HexString -> Integer -> Maybe BlockHash -> Maybe BlockHash -> Block blockHash :: Block -> BlockHash -- | The number of confirmations the block has. blkConfirmations :: Block -> Integer -- | The size of the block. blkSize :: Block -> Integer -- | The height of the block. TODO: Clarify this. blkHeight :: Block -> Integer -- | The version of the block. blkVersion :: Block -> Integer -- | The hash of the block at the root of the merkle tree which this block -- belongs to. merkleRoot :: Block -> BlockHash -- | Should this be a transaction, or transaction id? subTransactions :: Block -> Vector TransactionID -- | The time it was mined. blkTime :: Block -> Integer -- | The block's nonce. blkNonce :: Block -> Integer blkBits :: Block -> HexString -- | How hard was this block to mine? blkDifficulty :: Block -> Integer -- | A pointer to the next block in the chain. nextBlock :: Block -> Maybe BlockHash -- | A pointer to the previous block in the chain. prevBlock :: Block -> Maybe BlockHash -- | Returns details of a block with given block-hash. getBlock :: Auth -> BlockHash -> IO Block -- | Information on the unspent transaction in the output set. data OutputSetInfo OutputSetInfo :: BlockHash -> Integer -> Integer -> Integer -> OutputSetInfo osiBestBlock :: OutputSetInfo -> BlockHash -- | The number of transactions in the output set. numTransactions :: OutputSetInfo -> Integer -- | The number of outputs for the transactions. transactionOutputs :: OutputSetInfo -> Integer -- | The serialized size of the output set. serializedSize :: OutputSetInfo -> Integer -- | Returns statistics about the unspent transaction output set. getOutputSetInfo :: Auth -> IO OutputSetInfo -- | Details about an unspent transaction output. data OutputInfo OutputInfo :: BlockHash -> Integer -> BTC -> ScriptSig -> Integer -> Bool -> OutputInfo oiBestBlock :: OutputInfo -> BlockHash -- | The number of times this transaction has been confirmed. oiConfirmations :: OutputInfo -> Integer -- | The amount transferred. oiAmount :: OutputInfo -> BTC -- | The public key of the sender. oiScriptPubKey :: OutputInfo -> ScriptSig -- | The version of this transaction. oiVersion :: OutputInfo -> Integer -- | Is this transaction part of the coin base? oiCoinBase :: OutputInfo -> Bool -- | Returns details about an unspent transaction output. getOutputInfo :: Auth -> TransactionID -> Integer -> IO OutputInfo -- | Adds a private key (as returned by dumpprivkey) to your wallet. importPrivateKey :: Auth -> PrivateKey -> Maybe Account -> IO () -- | Reveals the private key corresponding to the given address. dumpPrivateKey :: Auth -> Address -> IO PrivateKey -- | Returns whether or not bitcoind is generating bitcoins. getGenerate :: Auth -> IO Bool -- | Controls whether or not bitcoind is generating bitcoins. setGenerate :: Auth -> Bool -> Maybe Int -> IO () -- | Returns a recent hashes per second performance measurement while -- generating. getHashesPerSec :: Auth -> IO Integer -- | Information related to the current bitcoind mining operation. -- -- If a field is undocumented here, it's because I don't know what it -- means. If you DO know what it means, I'd love it if you would submit a -- patch to help complete this documentation. data MiningInfo MiningInfo :: Integer -> Integer -> Integer -> Double -> Text -> Bool -> Integer -> Integer -> Integer -> Bool -> MiningInfo -- | The number of blocks in our block-chain. nBlocks :: MiningInfo -> Integer -- | The size of the current block we're mining. currentBlockSize :: MiningInfo -> Integer currentBlockTransaction :: MiningInfo -> Integer -- | How difficult mining currently is. difficulty :: MiningInfo -> Double -- | Any mining errors that may have come up. miningErrors :: MiningInfo -> Text -- | Are we currently generating bitcoins? isGenerating :: MiningInfo -> Bool -- | How many processors have we limited bitcoin mining to? generationProcessorLimit :: MiningInfo -> Integer -- | How fast is the mining going? hashesPerSecond :: MiningInfo -> Integer pooledTransactions :: MiningInfo -> Integer -- | Are we on the bitcoin test network (as opposed to the real thing)? miningOnTestNetwork :: MiningInfo -> Bool -- | Returns an object containing mining-related information. getMiningInfo :: Auth -> IO MiningInfo -- | The hash data returned from getWork. data HashData HashData :: HexString -> HexString -> HexString -> HexString -> HashData blockData :: HashData -> HexString -- | Little-endian hash target, formatted as a hexadecimal string. hdTarget :: HashData -> HexString hash1 :: HashData -> HexString midstate :: HashData -> HexString -- | Returns formatted hash data to work on. getWork :: Auth -> IO HashData -- | Tries to solve the given block, and returns true if it was successful. solveBlock :: Auth -> HexString -> IO Bool -- | A transaction to be included in the next block. data Transaction Transaction :: HexString -> HexString -> Vector Integer -> Maybe Integer -> Integer -> Transaction txnData :: Transaction -> HexString txnHash :: Transaction -> HexString depends :: Transaction -> Vector Integer txnFee :: Transaction -> Maybe Integer sigOps :: Transaction -> Integer data CoinBaseAux CoinBaseAux :: HexString -> CoinBaseAux cbFlags :: CoinBaseAux -> HexString -- | A template for constructing a block to work on. -- -- See https://en.bitcoin.it/wiki/BIP_0022 for the full -- specification. data BlockTemplate BlockTemplate :: Integer -> HexString -> Vector Transaction -> CoinBaseAux -> Integer -> HexString -> Integer -> HexString -> Integer -> Integer -> Integer -> HexString -> Integer -> BlockTemplate blockVersion :: BlockTemplate -> Integer -- | Hash of current highest block. previousBlockHash :: BlockTemplate -> HexString -- | Contents of non-coinbase transactions that should be included in the -- next block. transactionsToInclude :: BlockTemplate -> Vector Transaction -- | Data that should be included in coinbase. coinBaseAux :: BlockTemplate -> CoinBaseAux -- | Maximum allowable input to coinbase transaction, including the -- generation award and transaction fees. coinBaseValue :: BlockTemplate -> Integer -- | Hash target. btTarget :: BlockTemplate -> HexString -- | Minimum timestamp appropriate for next block. minTime :: BlockTemplate -> Integer -- | Range of valid nonces. nonceRange :: BlockTemplate -> HexString -- | Limit of sigops in blocks. sigopLimit :: BlockTemplate -> Integer -- | Limit of block size. sizeLimit :: BlockTemplate -> Integer -- | Current timestamp. curTime :: BlockTemplate -> Integer -- | Compressed target of the next block. btBits :: BlockTemplate -> HexString -- | Height of the next block. btHeight :: BlockTemplate -> Integer -- | Returns data needed to construct a block to work on. getBlockTemplate :: Auth -> IO BlockTemplate -- | Attempts to submit a new block to the network. submitBlock :: Auth -> HexString -> IO Bool -- | Returns the number of connections to other nodes. getConnectionCount :: Auth -> IO Integer -- | Information about a peer node of the Bitcoin network. -- -- The documentation for this data structure is incomplete, as I honestly -- don't know what some of these fields are for. Patches are welcome! data PeerInfo PeerInfo :: Text -> Text -> Integer -> Integer -> Integer -> Integer -> Text -> Bool -> Integer -> Integer -> Integer -> PeerInfo -- | The IP:port of this peer, as a string. addressName :: PeerInfo -> Text services :: PeerInfo -> Text -- | Relative to the first time we conected with this peer (and in -- milliseconds), the last time we sent this peer any data. lastSend :: PeerInfo -> Integer -- | Relative to the first time we connected with this peer (and in -- milliseconds), the last time we sent this peer any data. lastRecv :: PeerInfo -> Integer -- | How long have we been connected to this peer (in milliseconds). connectionTime :: PeerInfo -> Integer -- | The version of the Bitcion client the peer is running. peerVersion :: PeerInfo -> Integer -- | The sub-version of the Bitcoin client the peer is running. peerSubversion :: PeerInfo -> Text inbound :: PeerInfo -> Bool releaseTime :: PeerInfo -> Integer startingHeight :: PeerInfo -> Integer -- | How many times has this peer behaved badly? banScore :: PeerInfo -> Integer -- | Returns data about all connected peer nodes. getPeerInfo :: Auth -> IO [PeerInfo] -- | Just like most binary data retrieved from bitcoind, a raw transaction -- is represented by a hexstring. -- -- This is a serialized, hex-encoded transaction. type RawTransaction = HexString -- | Get a raw transaction from its unique ID. getRawTransaction :: Auth -> TransactionID -> IO RawTransaction -- | A transaction into an account. This can either be a coinbase -- transaction, or a standard transaction with another account. data TxIn TxCoinbase :: HexString -> TxIn txCoinbase :: TxIn -> HexString TxIn :: TransactionID -> Integer -> ScriptSig -> Integer -> TxIn -- | This transaction's ID. txInId :: TxIn -> TransactionID numOut :: TxIn -> Integer scriptSig :: TxIn -> ScriptSig -- | A transaction sequence number. txSequence :: TxIn -> Integer -- | The type of a transaction out. -- -- More documentation is needed here. Submit a patch if you know what -- this is about! data TxnOutputType -- | JSON of pubkey received. TxnPubKey :: TxnOutputType -- | JSON of pubkeyhash received. TxnPubKeyHash :: TxnOutputType -- | JSON of scripthash received. TxnScriptHash :: TxnOutputType -- | JSON of multisig received. TxnMultisig :: TxnOutputType -- | A public key of someone we sent money to. data ScriptPubKey NonStandardScriptPubKey :: HexString -> HexString -> ScriptPubKey -- | The JSON asm field. nspkAsm :: ScriptPubKey -> HexString -- | The JSON hex field. nspkHex :: ScriptPubKey -> HexString StandardScriptPubKey :: HexString -> HexString -> Integer -> TxnOutputType -> Vector Address -> ScriptPubKey -- | The JSON asm field. sspkAsm :: ScriptPubKey -> HexString -- | The JSON hex field. sspkHex :: ScriptPubKey -> HexString -- | The number of required signatures. requiredSigs :: ScriptPubKey -> Integer -- | The type of the transaction. sspkType :: ScriptPubKey -> TxnOutputType -- | The addresses associated with this key. sspkAddresses :: ScriptPubKey -> Vector Address -- | A transaction out of an account. data TxOut TxOut :: BTC -> ScriptPubKey -> TxOut -- | The amount of bitcoin transferred out. txoutVal :: TxOut -> BTC -- | The public key of the account we sent the money to. scriptPubKey :: TxOut -> ScriptPubKey -- | Information on a single block. data BlockInfo ConfirmedBlock :: Integer -> Integer -> Integer -> BlockInfo -- | The number of confirmations a block has. This will always be >= 1. confirmations :: BlockInfo -> Integer cbTime :: BlockInfo -> Integer -- | The JSON blocktime field. blockTime :: BlockInfo -> Integer -- | An unconfirmed block is boring, but a possibility. UnconfirmedBlock :: BlockInfo -- | The raw transaction info for a given transaction ID. data RawTransactionInfo RawTransactionInfo :: RawTransaction -> Integer -> Integer -> Vector TxIn -> Vector TxOut -> HexString -> BlockInfo -> RawTransactionInfo -- | The raw transaction. raw :: RawTransactionInfo -> RawTransaction -- | The transaction version number. txnVersion :: RawTransactionInfo -> Integer txnLockTime :: RawTransactionInfo -> Integer -- | The vector of transactions in. vin :: RawTransactionInfo -> Vector TxIn -- | The vector of transactions out. vout :: RawTransactionInfo -> Vector TxOut -- | The hash of the block that was used for this transaction. rawTxBlockHash :: RawTransactionInfo -> HexString -- | The transaction's block's info. rawBlockInfo :: RawTransactionInfo -> BlockInfo -- | Get raw transaction info for a given transaction ID. The data -- structure returned is quite sprawling and undocumented, so any patches -- to help simplify things would be greatly appreciated. getRawTransactionInfo :: Auth -> TransactionID -> IO RawTransactionInfo data UnspentTransaction UnspentTransaction :: TransactionID -> Integer -> HexString -> Maybe HexString -> BTC -> Integer -> UnspentTransaction unspentTransactionId :: UnspentTransaction -> TransactionID outIdx :: UnspentTransaction -> Integer unspentScriptPubKey :: UnspentTransaction -> HexString redeemScript :: UnspentTransaction -> Maybe HexString unspentAmount :: UnspentTransaction -> BTC usConfirmations :: UnspentTransaction -> Integer -- | Returns an array of unspent transaction outputs with between minconf -- and maxconf (inclusive) confirmations. If addresses are given, the -- result will be filtered to include only those addresses. listUnspent :: Auth -> Maybe Int -> Maybe Int -> Vector Address -> IO (Vector UnspentTransaction) -- | Create a transaction spending given inputs, sending to given -- addresses. -- -- Note that the transaction's inputs are not signed, and it is not -- stored in the wallet or transmitted to the network. -- -- Also, there is no checking to see if it's possible to send that much -- to the targets specified. In the future, such a scenario might throw -- an exception. createRawTransaction :: Auth -> Vector UnspentTransaction -> Vector (Address, BTC) -> IO HexString -- | A successfully decoded raw transaction, from a given serialized, -- hex-encoded transaction. data DecodedRawTransaction DecodedRawTransaction :: RawTransaction -> Integer -> Integer -> Vector TxIn -> Vector TxOut -> DecodedRawTransaction -- | The raw transaction. decRaw :: DecodedRawTransaction -> RawTransaction -- | The transaction version number. decTxnVersion :: DecodedRawTransaction -> Integer decTxnLockTime :: DecodedRawTransaction -> Integer -- | The vector of transactions in. decVin :: DecodedRawTransaction -> Vector TxIn -- | The vector of transactions out. decVout :: DecodedRawTransaction -> Vector TxOut -- | Decodes a raw transaction into a more accessible data structure. decodeRawTransaction :: Auth -> RawTransaction -> IO DecodedRawTransaction -- | Who can pay for a given transaction. data WhoCanPay All :: WhoCanPay AllOrAnyoneCanPay :: WhoCanPay None :: WhoCanPay NoneOrAnyoneCanPay :: WhoCanPay Single :: WhoCanPay SingleOrAnyoneCanPay :: WhoCanPay -- | A raw signed transaction contains the raw, signed hexstring and -- whether or not this transaction has a complete signature set. data RawSignedTransaction RawSignedTransaction :: HexString -> Bool -> RawSignedTransaction rawSigned :: RawSignedTransaction -> HexString hasCompleteSigSet :: RawSignedTransaction -> Bool -- | Sign inputs for a raw transaction. signRawTransaction :: Auth -> RawTransaction -> Maybe (Vector UnspentTransaction) -> Maybe (Vector HexString) -> Maybe WhoCanPay -> IO RawSignedTransaction sendRawTransaction :: Auth -> RawTransaction -> IO TransactionID -- | A plethora of information about a bitcoind instance. data BitcoindInfo BitcoindInfo :: Integer -> Integer -> Integer -> BTC -> Integer -> Integer -> Text -> Double -> Bool -> Integer -> Integer -> BTC -> Maybe Integer -> Text -> BitcoindInfo -- | What version of bitcoind are we running? bitcoinVersion :: BitcoindInfo -> Integer -- | What is bitcoind's current protocol number? protocolVersion :: BitcoindInfo -> Integer -- | What version is the wallet? walletVersion :: BitcoindInfo -> Integer -- | How much money is currently in the wallet? balance :: BitcoindInfo -> BTC -- | The number of blocks in our chain. numBlocks :: BitcoindInfo -> Integer -- | How many peers are we connected to? numConnections :: BitcoindInfo -> Integer -- | A blank string if we're not using a proxy. proxy :: BitcoindInfo -> Text -- | The difficulty multiplier for bitcoin mining operations. generationDifficulty :: BitcoindInfo -> Double -- | Are we on the test network (as opposed to the primary bitcoin -- network)? onTestNetwork :: BitcoindInfo -> Bool -- | The timestamp of the oldest key in the key pool. keyPoolOldest :: BitcoindInfo -> Integer -- | The size of the key pool. keyPoolSize :: BitcoindInfo -> Integer -- | How much do we currently pay as a transaction fee? transactionFeePaid :: BitcoindInfo -> BTC -- | If the wallet is unlocked, the number of seconds until a re-lock is -- needed. unlockedUntil :: BitcoindInfo -> Maybe Integer -- | Any alerts will show up here. This should normally be an empty string. bitcoindErrors :: BitcoindInfo -> Text -- | Returns an object containing various state info. getBitcoindInfo :: Auth -> IO BitcoindInfo -- | Returns a new bitcoin address for receiving payments. -- -- If an account is specified (recommended), the new address is added to -- the address book so payments received with the address will be -- credited to the given account. -- -- If no account is specified, the address will be credited to the -- account whose name is the empty string. i.e. the default account. getNewAddress :: Auth -> Maybe Account -> IO Address -- | Returns the current Bitcoin address for receiving payments to the -- given account. getAccountAddress :: Auth -> Account -> IO Address -- | Returns the account associated with the given address. getAccount :: Auth -> Address -> IO Account -- | Sets the account associated with the given address. setAccount :: Auth -> Address -> Account -> IO () -- | Returns the list of addresses for the given address. getAddressesByAccount :: Auth -> Account -> IO (Vector Address) -- | Sends some bitcoins to an address. sendToAddress :: Auth -> Address -> BTC -> Maybe Text -> Maybe Text -> IO TransactionID -- | Information on a given address. data AddressInfo AddressInfo :: Address -> BTC -> Maybe Account -> AddressInfo -- | The address in question. aiAddress :: AddressInfo -> Address -- | The address' balance. aiAmount :: AddressInfo -> BTC -- | The address' linked account. aiAccount :: AddressInfo -> Maybe Account -- | Lists groups of addresses which have had their common ownership made -- public by common use as inputs or as the resulting change in past -- transactions. listAddressGroupings :: Auth -> IO (Vector (Vector AddressInfo)) -- | A signature is a base-64 encoded string. type Signature = HexString -- | Sign a message with the private key of an address. signMessage :: Auth -> Address -> Text -> IO Signature -- | Verifies a signed message. verifyMessage :: Auth -> Address -> Signature -> Text -> IO Bool -- | Returns the total amount received by the given address with at least -- one confirmation. getReceivedByAddress :: Auth -> Address -> IO BTC -- | Returns the total amount received by the given address, with at least -- the give number of confirmations. getReceivedByAddress' :: Auth -> Address -> Int -> IO BTC -- | Returns the total amount received by address with the given account. getReceivedByAccount :: Auth -> Account -> IO BTC -- | Returns the total amount received by addresses with the given account, -- counting only transactions with the given minimum number of -- confirmations. getReceivedByAccount' :: Auth -> Account -> Int -> IO BTC -- | Returns the server's total available balance. getBalance :: Auth -> IO BTC -- | Returns the balance in the given account, counting only transactions -- with at least one confirmation. getBalance' :: Auth -> Account -> IO BTC -- | Returns the balance in the given account, counting only transactions -- with at least the given number of confirmations. getBalance'' :: Auth -> Account -> Int -> IO BTC -- | Move bitcoins from one account in your wallet to another. -- -- If you want to send bitcoins to an address not in your wallet, use -- sendFromAccount. moveBitcoins :: Auth -> Account -> Account -> BTC -> Text -> IO () -- | Sends bitcoins from a given account in our wallet to a given address. -- -- A transaction and sender comment may be optionally provided. sendFromAccount :: Auth -> Account -> Address -> BTC -> Maybe Text -> Maybe Text -> IO TransactionID -- | Send to a whole bunch of address at once. sendMany :: Auth -> Account -> Vector (Address, BTC) -> Maybe Text -> IO TransactionID -- | Information on how much was received by a given address. data ReceivedByAddress ReceivedByAddress :: Address -> Account -> BTC -> Integer -> ReceivedByAddress -- | The address which the money was deposited to. recvAddress :: ReceivedByAddress -> Address -- | The account which this address belongs to. recvAccount :: ReceivedByAddress -> Account -- | The amount received. recvAmount :: ReceivedByAddress -> BTC -- | The number of confirmations of the most recent included transaction. recvNumConfirmations :: ReceivedByAddress -> Integer -- | Lists the amount received by each address which has received money at -- some point, counting only transactions with at least one confirmation. listReceivedByAddress :: Auth -> IO (Vector ReceivedByAddress) -- | List the amount received by each of our addresses, counting only -- transactions with the given minimum number of confirmations. listReceivedByAddress' :: Auth -> Int -> Bool -> IO (Vector ReceivedByAddress) data ReceivedByAccount ReceivedByAccount :: Account -> BTC -> Integer -> ReceivedByAccount -- | The account we received into. raccAccount :: ReceivedByAccount -> Account -- | The mount received. ^ The number of confirmations of the most recent -- included transaction. raccAmount :: ReceivedByAccount -> BTC raccNumConfirmations :: ReceivedByAccount -> Integer -- | Lists the amount received by each account which has received money at -- some point, counting only transactions with at leaset one -- confirmation. listReceivedByAccount :: Auth -> IO (Vector ReceivedByAccount) -- | List the amount received by each of our accounts, counting only -- transactions with the given minimum number of confirmations. listReceivedByAccount' :: Auth -> Int -> Bool -> IO (Vector ReceivedByAccount) -- | Safely copies wallet.dat to the given destination, which can be either -- a directory, or a path with filename. backupWallet :: Auth -> FilePath -> IO () -- | Fills the keypool. keyPoolRefill :: Auth -> IO () -- | Stores the wallet decryption key in memory for the given amount of -- time. unlockWallet :: Auth -> Text -> Integer -> IO () -- | Removes the wallet encryption key from memory, locking the wallet. -- -- After calling this function, you will need to call unlockWallet -- again before being able to call methods which require the wallet to be -- unlocked. -- -- Note: In future releases, we might introduce an unlocked monad, -- so locking and unlocking is automatic. lockWallet :: Auth -> IO () -- | Changes the wallet passphrase. changePassword :: Auth -> Text -> Text -> IO () -- | Encrypts the wallet with the given passphrase. -- -- WARNING: bitcoind will shut down after calling this method. Don't say -- I didn't warn you. encryptWallet :: Auth -> Text -> IO () -- | Checks if a given address is a valid one. isAddressValid :: Auth -> Address -> IO Bool