network-bitcoin-1.2.2: An interface to bitcoind.

Safe HaskellNone



An interface to bitcoind's available block-chain-related RPC calls. The implementation of these functions can be found at

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.



data Auth Source

Auth describes authentication credentials for making API requests to the Bitcoin daemon.




rpcUrl :: Text

URL, with port, where bitcoind listens

rpcUser :: Text

same as bitcoind's rpcuser config

rpcPassword :: Text

same as bitcoind's rpcpassword config


type TransactionID = HexStringSource

A hexadecimal string representation of a 256-bit unsigned integer.

This integer is a unique transaction identifier.

type BTC = Fixed SatoshiSource

The type of bitcoin money, represented with a fixed-point number.

data ScriptSig Source

I don't know what this is. A signature of some sort? If you know, please submit a patch documenting this properly!



getBlockCount :: Auth -> IO IntegerSource

Returns the number of blocks in the longest block chain.

getDifficulty :: Auth -> IO IntegerSource

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

setTransactionFee :: Auth -> BTC -> IO ()Source

Sets the transaction fee will will pay to the network. Values of 0 are rejected.

getRawMemoryPool :: Auth -> IO (Vector TransactionID)Source

Returns all transaction identifiers in the memory pool.

type BlockHash = HexStringSource

The hash of a given block.



:: Auth 
-> Integer

Block index.

-> IO BlockHash 

Returns the hash of the block in best-block-chain at the given index.

data Block Source

Information about a given block in the block chain.




blockHash :: BlockHash
blkConfirmations :: Integer

The number of confirmations the block has.

blkSize :: Integer

The size of the block.

blkHeight :: Integer

The height of the block. TODO: Clarify this.

blkVersion :: Integer

The version of the block.

merkleRoot :: BlockHash

The hash of the block at the root of the merkle tree which this block belongs to.

subTransactions :: Vector TransactionID

Should this be a transaction, or transaction id?

blkTime :: Integer

The time it was mined.

blkNonce :: Integer

The block's nonce.

blkBits :: HexString
blkDifficulty :: Integer

How hard was this block to mine?

nextBlock :: Maybe BlockHash

A pointer to the next block in the chain.

prevBlock :: Maybe BlockHash

A pointer to the previous block in the chain.

getBlock :: Auth -> BlockHash -> IO BlockSource

Returns details of a block with given block-hash.

data OutputSetInfo Source

Information on the unspent transaction in the output set.




osiBestBlock :: BlockHash
numTransactions :: Integer

The number of transactions in the output set.

transactionOutputs :: Integer

The number of outputs for the transactions.

serializedSize :: Integer

The serialized size of the output set.

getOutputSetInfo :: Auth -> IO OutputSetInfoSource

Returns statistics about the unspent transaction output set.

data OutputInfo Source

Details about an unspent transaction output.




oiBestBlock :: BlockHash
oiConfirmations :: Integer

The number of times this transaction has been confirmed.

oiAmount :: BTC

The amount transferred.

oiScriptPubKey :: ScriptSig

The public key of the sender.

oiVersion :: Integer

The version of this transaction.

oiCoinBase :: Bool

Is this transaction part of the coin base?



:: Auth 
-> TransactionID 
-> Integer

The index we're looking at.

-> IO OutputInfo 

Returns details about an unspent transaction output.