network-bitcoin-1.8.0: An interface to bitcoind.

Safe HaskellNone
LanguageHaskell98

Network.Bitcoin.RawTransaction

Description

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.

Synopsis

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.

type RawTransaction = HexString Source

Just like most binary data retrieved from bitcoind, a raw transaction is represented by a hexstring.

This is a serialized, hex-encoded transaction.

getRawTransaction :: Client -> TransactionID -> IO RawTransaction Source

Get a raw transaction from its unique ID.

data TxIn Source

A transaction into an account. This can either be a coinbase transaction, or a standard transaction with another account.

Constructors

TxCoinbase 
TxIn 

Fields

txInId :: TransactionID

This transaction's ID.

numOut :: Integer
 
scriptSig :: ScriptSig
 
txSequence :: Integer

A transaction sequence number.

data TxnOutputType Source

The type of a transaction out.

More documentation is needed here. Submit a patch if you know what this is about!

Constructors

TxnPubKey

JSON of "pubkey" received.

TxnPubKeyHash

JSON of "pubkeyhash" received.

TxnScriptHash

JSON of "scripthash" received.

TxnMultisig

JSON of "multisig" received.

data ScriptPubKey Source

A public key of someone we sent money to.

Constructors

NonStandardScriptPubKey 

Fields

nspkAsm :: HexString

The JSON "asm" field.

nspkHex :: HexString

The JSON "hex" field.

StandardScriptPubKey 

Fields

sspkAsm :: HexString

The JSON "asm" field.

sspkHex :: HexString

The JSON "hex" field.

requiredSigs :: Integer

The number of required signatures.

sspkType :: TxnOutputType

The type of the transaction.

sspkAddresses :: Vector Address

The addresses associated with this key.

data ScriptSig Source

A script signature.

Constructors

ScriptSig 

data TxOut Source

A transaction out of an account.

Constructors

TxOut 

Fields

txoutVal :: BTC

The amount of bitcoin transferred out.

scriptPubKey :: ScriptPubKey

The public key of the account we sent the money to.

data BlockInfo Source

Information on a single block.

Constructors

ConfirmedBlock 

Fields

confirmations :: Integer

The number of confirmations a block has. This will always be >= 1.

cbTime :: Integer
 
blockTime :: Integer

The JSON "blocktime" field.

UnconfirmedBlock

An unconfirmed block is boring, but a possibility.

data RawTransactionInfo Source

The raw transaction info for a given transaction ID.

Constructors

RawTransactionInfo 

Fields

raw :: RawTransaction

The raw transaction.

txnVersion :: Integer

The transaction version number.

txnLockTime :: Integer
 
vin :: Vector TxIn

The vector of transactions in.

vout :: Vector TxOut

The vector of transactions out.

rawTxBlockHash :: HexString

The hash of the block that was used for this transaction.

rawBlockInfo :: BlockInfo

The transaction's block's info.

getRawTransactionInfo :: Client -> TransactionID -> IO RawTransactionInfo Source

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.

listUnspent Source

Arguments

:: Client 
-> Maybe Int

minconf. Defaults to 1 if Nothing.

-> Maybe Int

maxconf. Defaults to 9999999 if Nothing.

-> Vector Address

Use empty for no filtering.

-> IO (Vector UnspentTransaction) 

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.

createRawTransaction Source

Arguments

:: Client 
-> Vector UnspentTransaction

The unspent transactions we'll be using as our output.

-> Vector (Address, BTC)

The addresses we're sending money to, along with how much each of them gets.

-> IO HexString 

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.

data DecodedRawTransaction Source

A successfully decoded raw transaction, from a given serialized, hex-encoded transaction.

Constructors

DecodedRawTransaction 

Fields

decRaw :: RawTransaction

The raw transaction.

decTxnVersion :: Integer

The transaction version number.

decTxnLockTime :: Integer
 
decVin :: Vector TxIn

The vector of transactions in.

decVout :: Vector TxOut

The vector of transactions out.

decodeRawTransaction :: Client -> RawTransaction -> IO DecodedRawTransaction Source

Decodes a raw transaction into a more accessible data structure.

data WhoCanPay Source

Who can pay for a given transaction.

data RawSignedTransaction Source

A raw signed transaction contains the raw, signed hexstring and whether or not this transaction has a complete signature set.

signRawTransaction Source

Arguments

:: Client 
-> RawTransaction

The raw transaction whose inputs we're signing.

-> Maybe (Vector UnspentTransaction)

An optional list of previous transaction outputs that this transaction depends on but may not yet be in the block chain.

-> Maybe (Vector HexString)

An array of base58-encoded private keys that, if given, will be the only keys used to sign the transaction.

-> Maybe WhoCanPay

Who can pay for this transaction? All by default.

-> IO RawSignedTransaction

Returns Nothing if the transaction has a complete set of signatures, and the raw signed transa

Sign inputs for a raw transaction.