Safe Haskell | None |
---|---|
Language | Haskell98 |
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.
- type Client = ByteString -> IO ByteString
- getClient :: String -> ByteString -> ByteString -> IO Client
- getGenerate :: Client -> IO Bool
- setGenerate :: Client -> Bool -> Maybe Int -> IO ()
- getHashesPerSec :: Client -> IO Integer
- data MiningInfo = MiningInfo {}
- getMiningInfo :: Client -> IO MiningInfo
- data HashData = HashData {}
- getWork :: Client -> IO HashData
- solveBlock :: Client -> HexString -> IO Bool
- data Transaction = Transaction {}
- data CoinBaseAux = CoinBaseAux {}
- data BlockTemplate = BlockTemplate {
- blockVersion :: Integer
- previousBlockHash :: HexString
- transactionsToInclude :: Vector Transaction
- coinBaseAux :: CoinBaseAux
- coinBaseValue :: Integer
- btTarget :: HexString
- minTime :: Integer
- nonceRange :: HexString
- sigopLimit :: Integer
- sizeLimit :: Integer
- curTime :: Integer
- btBits :: HexString
- btHeight :: Integer
- getBlockTemplate :: Client -> IO BlockTemplate
- submitBlock :: Client -> HexString -> IO Bool
Documentation
type Client = ByteString -> IO ByteString Source
Client
describes authentication credentials and host info for
making API requests to the Bitcoin daemon.
getClient :: String -> ByteString -> ByteString -> IO Client Source
getClient
takes a url, rpc username, and rpc password
and returns a Client that can be used to make API calls. Each
Client encloses a Manager (from http-client) that re-uses
connections for requests, so long as the same Client is
is used for each call.
Returns whether or not bitcoind is generating bitcoins.
:: Client | bitcoind RPC client |
-> 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 :: Client -> IO Integer Source
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.
MiningInfo | |
|
getMiningInfo :: Client -> IO MiningInfo Source
Returns an object containing mining-related information.
solveBlock :: Client -> HexString -> IO Bool Source
Tries to solve the given block, and returns true if it was successful.
data CoinBaseAux Source
data BlockTemplate Source
A template for constructing a block to work on.
See https://en.bitcoin.it/wiki/BIP_0022 for the full specification.
BlockTemplate | |
|
getBlockTemplate :: Client -> IO BlockTemplate Source
Returns data needed to construct a block to work on.