network-bitcoin-1.0.2: An interface to bitcoind.

Safe HaskellNone

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

data Auth Source

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

Constructors

Auth 

Fields

rpcUrl :: Text

URL, with port, where bitcoind listens

rpcUser :: Text

same as bitcoind's rpcuser config

rpcPassword :: Text

same as bitcoind's rpcpassword config

Instances

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!

Constructors

ScriptSig 

type RawTransaction = HexStringSource

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

This is a serialized, hex-encoded transaction.

getRawTransaction :: Auth -> TransactionID -> IO RawTransactionSource

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 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 :: Auth -> TransactionID -> IO RawTransactionInfoSource

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.

listUnspentSource

Arguments

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

createRawTransactionSource

Arguments

:: Auth 
-> 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 :: Auth -> RawTransaction -> IO DecodedRawTransactionSource

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.

signRawTransactionSource

Arguments

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