network-bitcoin-1.4.0: An interface to bitcoind.

Safe HaskellNone



An interface to bitcoind's available mining 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.

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



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




:: Auth

bitcoind RPC authorization

-> IO Bool 

Returns whether or not bitcoind is generating bitcoins.



:: Auth

bitcoind RPC authorization

-> Bool

Turn it on, or turn it off?

-> Maybe Int

Generation is limited to this number of processors. Set it to Nothing to keep the value at what it was before, Just -1 to use all available cores, and any other value to limit it.

-> IO () 

Controls whether or not bitcoind is generating bitcoins.

getHashesPerSec :: Auth -> IO IntegerSource

Returns a recent hashes per second performance measurement while generating.

data MiningInfo Source

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.




nBlocks :: Integer

The number of blocks in our block-chain.

currentBlockSize :: Integer

The size of the current block we're mining.

currentBlockTransaction :: Integer
difficulty :: Double

How difficult mining currently is.

miningErrors :: Text

Any mining errors that may have come up.

isGenerating :: Bool

Are we currently generating bitcoins?

generationProcessorLimit :: Integer

How many processors have we limited bitcoin mining to?

hashesPerSecond :: Integer

How fast is the mining going?

pooledTransactions :: Integer
miningOnTestNetwork :: Bool

Are we on the bitcoin test network (as opposed to the real thing)?

getMiningInfo :: Auth -> IO MiningInfoSource

Returns an object containing mining-related information.

data HashData Source

The hash data returned from getWork.




blockData :: HexString
hdTarget :: HexString

Little-endian hash target, formatted as a hexadecimal string.

hash1 :: HexString
midstate :: HexString

getWork :: Auth -> IO HashDataSource

Returns formatted hash data to work on.

solveBlock :: Auth -> HexString -> IO BoolSource

Tries to solve the given block, and returns true if it was successful.

data Transaction Source

A transaction to be included in the next block.

data BlockTemplate Source

A template for constructing a block to work on.

See for the full specification.




blockVersion :: Integer
previousBlockHash :: HexString

Hash of current highest block.

transactionsToInclude :: Vector Transaction

Contents of non-coinbase transactions that should be included in the next block.

coinBaseAux :: CoinBaseAux

Data that should be included in coinbase.

coinBaseValue :: Integer

Maximum allowable input to coinbase transaction, including the generation award and transaction fees.

btTarget :: HexString

Hash target.

minTime :: Integer

Minimum timestamp appropriate for next block.

nonceRange :: HexString

Range of valid nonces.

sigopLimit :: Integer

Limit of sigops in blocks.

sizeLimit :: Integer

Limit of block size.

curTime :: Integer

Current timestamp.

btBits :: HexString

Compressed target of the next block.

btHeight :: Integer

Height of the next block.

getBlockTemplate :: Auth -> IO BlockTemplateSource

Returns data needed to construct a block to work on.



:: Auth 
-> HexString

The block to submit.

-> IO Bool

Was the block accepted by the network?

Attempts to submit a new block to the network.