network-bitcoin-1.7.1: An interface to bitcoind.

Safe HaskellNone
LanguageHaskell98

Network.Bitcoin.BlockChain

Description

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.

Synopsis

Documentation

type Client = ByteString -> IO ByteString Source

Client describes authentication credentials and host info for making API requests to the Bitcoin daemon.

type TransactionID = HexString Source

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

This integer is a unique transaction identifier.

type BTC = Fixed Satoshi Source

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

getBlockCount :: Client -> IO Integer Source

Returns the number of blocks in the longest block chain.

getDifficulty :: Client -> IO Integer Source

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

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

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

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

Returns all transaction identifiers in the memory pool.

type BlockHash = HexString Source

The hash of a given block.

getBlockHash Source

Arguments

:: Client 
-> 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.

Constructors

Block 

Fields

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 :: Client -> BlockHash -> IO Block Source

Returns details of a block with given block-hash.

data OutputSetInfo Source

Information on the unspent transaction in the output set.

Constructors

OutputSetInfo 

Fields

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 :: Client -> IO OutputSetInfo Source

Returns statistics about the unspent transaction output set.

data OutputInfo Source

Details about an unspent transaction output.

Constructors

OutputInfo 

Fields

oiBestBlock :: BlockHash
 
oiConfirmations :: Integer

The number of times this transaction has been confirmed.

oiAmount :: BTC

The amount transferred.

oiScriptPubKey :: ScriptPubKey

The public key of the sender.

oiVersion :: Integer

The version of this transaction.

oiCoinBase :: Bool

Is this transaction part of the coin base?

getOutputInfo Source

Arguments

:: Client 
-> TransactionID 
-> Integer

The index we're looking at.

-> IO OutputInfo 

Returns details about an unspent transaction output.