iota.lib.cpp
IOTA C++ Library
Public Member Functions | Protected Member Functions | List of all members
IOTA::Models::Bundle Class Reference

#include <bundle.hpp>

Public Member Functions

 Bundle ()=default
 
 ~Bundle ()=default
 
 Bundle (const std::vector< Transaction > &transactions)
 
const std::vector< Transaction > & getTransactions () const
 
std::vector< Transaction > & getTransactions ()
 
const Types::Trytes & getHash () const
 
void setHash (const Types::Trytes &hash)
 
std::size_t getLength () const
 
bool empty () const
 
void addTransaction (const Transaction &transaction, int32_t signatureMessageLength=1)
 
void finalize ()
 
void addTrytes (const std::vector< Types::Trytes > &signatureFragments)
 
std::vector< int8_t > normalizedBundle (const Types::Trytes &bundleHash)
 
bool operator< (const Bundle &rhs) const
 
bool operator> (const Bundle &rhs) const
 
bool operator== (const Bundle &rhs) const
 
bool operator!= (const Bundle &rhs) const
 
Transactionoperator[] (const int index)
 
const Transactionoperator[] (const int index) const
 

Protected Member Functions

void generateHash (void)
 

Detailed Description

Bundle model.

Constructor & Destructor Documentation

◆ Bundle() [1/2]

IOTA::Models::Bundle::Bundle ( )
default

Default ctor.

◆ ~Bundle()

IOTA::Models::Bundle::~Bundle ( )
default

Default dtor.

◆ Bundle() [2/2]

IOTA::Models::Bundle::Bundle ( const std::vector< Transaction > &  transactions)
explicit

Initializes a new instance of the Bundle class with a list of transactions.

Parameters
transactionstransactions belonging to the same bundle.

Member Function Documentation

◆ addTransaction()

void IOTA::Models::Bundle::addTransaction ( const Transaction transaction,
int32_t  signatureMessageLength = 1 
)

Adds a bundle entry. If multiple signature fragments are required, generates as many transactions as necessary

Parameters
transactionTransaction to be added to the bundle.
signatureMessageLengthLength of the signature message.

◆ addTrytes()

void IOTA::Models::Bundle::addTrytes ( const std::vector< Types::Trytes > &  signatureFragments)

Adds the trytes.

Parameters
signatureFragmentsThe signature fragments.

◆ empty()

bool IOTA::Models::Bundle::empty ( ) const
Returns
whether the bundle is empty or not.

◆ finalize()

void IOTA::Models::Bundle::finalize ( )

Finalizes the bundle.

◆ generateHash()

void IOTA::Models::Bundle::generateHash ( void  )
protected

generate the hash corresponding to this bundle of transactions. This function does NOT check whether the normalized bundle contain 13 (security flaw). This method must remain private (or protected for tests purposed).

◆ getHash()

const Types::Trytes& IOTA::Models::Bundle::getHash ( ) const
Returns
bundle hash

◆ getLength()

std::size_t IOTA::Models::Bundle::getLength ( ) const
Returns
The length of the bundle.

◆ getTransactions() [1/2]

const std::vector<Transaction>& IOTA::Models::Bundle::getTransactions ( ) const
Returns
Bundle transactions.

◆ getTransactions() [2/2]

std::vector<Transaction>& IOTA::Models::Bundle::getTransactions ( )

Non-const getTransactions.

Returns
Bundle transactions.

◆ normalizedBundle()

std::vector<int8_t> IOTA::Models::Bundle::normalizedBundle ( const Types::Trytes &  bundleHash)

Normalized the bundle.

Parameters
bundleHashThe bundle hash.
Returns
A normalized bundle hash.

◆ operator!=()

bool IOTA::Models::Bundle::operator!= ( const Bundle rhs) const
Parameters
rhsAn object to compare with this object.
Returns
whether the current bundle is different from the given one.

◆ operator<()

bool IOTA::Models::Bundle::operator< ( const Bundle rhs) const
Parameters
rhsAn object to compare with this object.
Returns
whether the current bundle occured before the given one.

◆ operator==()

bool IOTA::Models::Bundle::operator== ( const Bundle rhs) const
Parameters
rhsAn object to compare with this object.
Returns
whether the current bundle is the same as the given one.

◆ operator>()

bool IOTA::Models::Bundle::operator> ( const Bundle rhs) const
Parameters
rhsAn object to compare with this object.
Returns
whether the current bundle occured after the given one.

◆ operator[]() [1/2]

Transaction& IOTA::Models::Bundle::operator[] ( const int  index)
Parameters
indexThe transaction index.
Returns
the Transaction at given index.

◆ operator[]() [2/2]

const Transaction& IOTA::Models::Bundle::operator[] ( const int  index) const
Parameters
indexThe transaction index.
Returns
the Transaction at given index.

◆ setHash()

void IOTA::Models::Bundle::setHash ( const Types::Trytes &  hash)

Set the hash of the bundle. This does NOT update the underlying transaction.

Parameters
hashNew hash for bundle

The documentation for this class was generated from the following file: