cbitcoin
 All Data Structures Files Functions Variables Typedefs
src/structures/CBObject/CBMessage/CBTransaction/CBTransaction.h File Reference

A CBTransaction represents a movement of bitcoins and newly mined bitcoins. Inherits CBMessage. More...

#include "CBMessage.h"
#include "CBTransactionInput.h"
#include "CBTransactionOutput.h"

Go to the source code of this file.

Data Structures

struct  CBTransaction
 Structure for CBTransaction objects. More...

Functions

CBTransactionCBNewTransaction (uint32_t lockTime, uint32_t version, void(*onErrorReceived)(CBError error, char *,...))
 Creates a new CBTransaction object with no inputs or outputs.
CBTransactionCBNewTransactionFromData (CBByteArray *bytes, void(*onErrorReceived)(CBError error, char *,...))
 Creates a new CBTransaction object from byte data. Should be serialised for object data.
CBTransactionCBGetTransaction (void *self)
 Gets a CBTransaction from another object. Use this to avoid casts.
bool CBInitTransaction (CBTransaction *self, uint32_t lockTime, uint32_t version, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a CBTransaction object.
bool CBInitTransactionFromData (CBTransaction *self, CBByteArray *data, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a new CBTransaction object from the byte data.
void CBFreeTransaction (void *self)
 Frees a CBTransaction object.
bool CBTransactionAddInput (CBTransaction *self, CBTransactionInput *input)
 Adds an CBTransactionInput to the CBTransaction.
bool CBTransactionAddOutput (CBTransaction *self, CBTransactionOutput *output)
 Adds an CBTransactionInput to the CBTransaction.
uint32_t CBTransactionCalculateLength (CBTransaction *self)
 Calculates the length needed to serialise the object.
uint32_t CBTransactionDeserialise (CBTransaction *self)
 Deserialises a CBTransaction so that it can be used as an object.
CBGetHashReturn CBTransactionGetInputHashForSignature (void *vself, CBByteArray *prevOutSubScript, uint32_t input, CBSignType signType, uint8_t *hash)
 Gets the hash for signing or signature checking for a transaction input. The transaction input needs to contain the outPointerHash, outPointerIndex and sequence. If these are modifed afterwards then the signiture is invalid.
bool CBTransactionIsCoinBase (CBTransaction *self)
 Determines if a transaction is a coinbase transaction or not.
uint32_t CBTransactionSerialise (CBTransaction *self)
 Serialises a CBTransaction to the byte data.
bool CBTransactionTakeInput (CBTransaction *self, CBTransactionInput *input)
 Adds an CBTransactionInput to the CBTransaction without retaining it.
bool CBTransactionTakeOutput (CBTransaction *self, CBTransactionOutput *output)
 Adds an CBTransactionInput to the CBTransaction without retaining it.

Detailed Description

A CBTransaction represents a movement of bitcoins and newly mined bitcoins. Inherits CBMessage.


Function Documentation

void CBFreeTransaction ( void *  self)

Frees a CBTransaction object.

Parameters:
selfThe CBTransaction object to free.
CBTransaction* CBGetTransaction ( void *  self)

Gets a CBTransaction from another object. Use this to avoid casts.

Parameters:
selfThe object to obtain the CBTransaction from.
Returns:
The CBTransaction object.
bool CBInitTransaction ( CBTransaction self,
uint32_t  lockTime,
uint32_t  version,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a CBTransaction object.

Parameters:
selfThe CBTransaction object to initialise
Returns:
true on success, false on failure.
bool CBInitTransactionFromData ( CBTransaction self,
CBByteArray data,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a new CBTransaction object from the byte data.

Parameters:
selfThe CBTransaction object to initialise
dataThe byte data.
Returns:
true on success, false on failure.
CBTransaction* CBNewTransaction ( uint32_t  lockTime,
uint32_t  version,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Creates a new CBTransaction object with no inputs or outputs.

Returns:
A new CBTransaction object.
CBTransaction* CBNewTransactionFromData ( CBByteArray bytes,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Creates a new CBTransaction object from byte data. Should be serialised for object data.

Returns:
A new CBTransaction object.
bool CBTransactionAddInput ( CBTransaction self,
CBTransactionInput input 
)

Adds an CBTransactionInput to the CBTransaction.

Parameters:
selfThe CBTransaction object.
inputThe CBTransactionInput object.
Returns:
true if the transaction input was added successfully and false on error.
bool CBTransactionAddOutput ( CBTransaction self,
CBTransactionOutput output 
)

Adds an CBTransactionInput to the CBTransaction.

Parameters:
selfThe CBTransaction object.
inputThe CBTransactionOutput object.
Returns:
true if the transaction output was added successfully and false on error.

Calculates the length needed to serialise the object.

Parameters:
selfThe CBTransaction object.
Returns:
The length read on success, 0 on failure.

Deserialises a CBTransaction so that it can be used as an object.

Parameters:
selfThe CBTransaction object
Returns:
The length read on success, 0 on failure.
CBGetHashReturn CBTransactionGetInputHashForSignature ( void *  vself,
CBByteArray prevOutSubScript,
uint32_t  input,
CBSignType  signType,
uint8_t *  hash 
)

Gets the hash for signing or signature checking for a transaction input. The transaction input needs to contain the outPointerHash, outPointerIndex and sequence. If these are modifed afterwards then the signiture is invalid.

Parameters:
vselfThe CBTransaction object.
prevOutSubScriptThe sub script from the output. Must be the correct one or the signiture will be invalid.
inputThe index of the input to sign.
signTypeThe type of signature to get the data for.
hashThe 32 byte data hash for signing or checking signatures.
Returns:
CB_TX_HASH_OK if the hash has been retreived with no problems. CB_TX_HASH_BAD is returned if the hash is invalid and CB_TX_HASH_ERR is returned upon an error.

Determines if a transaction is a coinbase transaction or not.

Parameters:
selfThe CBTransaction object.
Returns:
true if the transaction is a coin-base transaction or false if not.
uint32_t CBTransactionSerialise ( CBTransaction self)

Serialises a CBTransaction to the byte data.

Parameters:
selfThe CBTransaction object.
Returns:
The length read on success, 0 on failure.

Adds an CBTransactionInput to the CBTransaction without retaining it.

Parameters:
selfThe CBTransaction object.
inputThe CBTransactionInput object.
Returns:
true if the transaction input was taken successfully and false on error.

Adds an CBTransactionInput to the CBTransaction without retaining it.

Parameters:
selfThe CBTransaction object.
inputThe CBTransactionOutput object.
Returns:
true if the transaction output was taken successfully and false on error.