network-bitcoin-1.9.1: 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

Instances
Eq TxIn Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

Methods

(==) :: TxIn -> TxIn -> Bool #

(/=) :: TxIn -> TxIn -> Bool #

Ord TxIn Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

Methods

compare :: TxIn -> TxIn -> Ordering #

(<) :: TxIn -> TxIn -> Bool #

(<=) :: TxIn -> TxIn -> Bool #

(>) :: TxIn -> TxIn -> Bool #

(>=) :: TxIn -> TxIn -> Bool #

max :: TxIn -> TxIn -> TxIn #

min :: TxIn -> TxIn -> TxIn #

Read TxIn Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

Show TxIn Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

Methods

showsPrec :: Int -> TxIn -> ShowS #

show :: TxIn -> String #

showList :: [TxIn] -> ShowS #

FromJSON TxIn Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

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

StandardScriptPubKey 

Fields

data TxOut Source #

A transaction out of an account.

Constructors

TxOut 

Fields

Instances
Eq TxOut Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

Methods

(==) :: TxOut -> TxOut -> Bool #

(/=) :: TxOut -> TxOut -> Bool #

Ord TxOut Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

Methods

compare :: TxOut -> TxOut -> Ordering #

(<) :: TxOut -> TxOut -> Bool #

(<=) :: TxOut -> TxOut -> Bool #

(>) :: TxOut -> TxOut -> Bool #

(>=) :: TxOut -> TxOut -> Bool #

max :: TxOut -> TxOut -> TxOut #

min :: TxOut -> TxOut -> TxOut #

Read TxOut Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

Show TxOut Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

Methods

showsPrec :: Int -> TxOut -> ShowS #

show :: TxOut -> String #

showList :: [TxOut] -> ShowS #

FromJSON TxOut Source # 
Instance details

Defined in Network.Bitcoin.RawTransaction

data BlockInfo Source #

Information on a single block.

Constructors

ConfirmedBlock 

Fields

UnconfirmedBlock

An unconfirmed block is boring, but a possibility.

data RawTransactionInfo Source #

The raw transaction info for a given transaction ID.

Constructors

RawTransactionInfo 

Fields

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

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.