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

#include <address.hpp>

Public Types

enum  Type { NORMAL, MULTISIG }
 

Public Member Functions

 Address (const Types::Trytes &address="", const int64_t &balance=0, const int32_t &keyIndex=0, const int32_t &security=2, const Type &type=NORMAL)
 
 Address (const char *address, const int64_t &balance=0, const int32_t &keyIndex=0, const int32_t &security=2, const Type &type=NORMAL)
 
 Address (const Type &type)
 
 ~Address ()=default
 
const Types::Trytes & toTrytes () const
 
Types::Trytes toTrytesWithChecksum (bool validChecksum=false)
 
void setAddress (const Types::Trytes &address)
 
const Types::Trytes & getChecksum (bool validChecksum=false)
 
bool empty () const
 
void absorbDigests (const std::vector< uint8_t > &digests)
 
void finalize ()
 
bool validate (const std::vector< std::vector< uint8_t >> &digests)
 
const int64_t & getBalance () const
 
void setBalance (const int64_t &balance)
 
const int32_t & getKeyIndex () const
 
void setKeyIndex (const int32_t &keyIndex)
 
const int32_t & getSecurity () const
 
void setSecurity (const int32_t &security)
 
bool operator== (const Address &rhs) const
 
bool operator!= (const Address &rhs) const
 
bool operator== (const Types::Trytes &rhs) const
 
bool operator!= (const Types::Trytes &rhs) const
 

Detailed Description

Used to store addresses. Provides validity checks at construction / value set. Provides checksum generation. Any addresses stored represented with this class are ensured to be valid.

Constructor & Destructor Documentation

◆ Address() [1/3]

IOTA::Models::Address::Address ( const Types::Trytes &  address = "",
const int64_t &  balance = 0,
const int32_t &  keyIndex = 0,
const int32_t &  security = 2,
const Type &  type = NORMAL 
)

Ctor.

Parameters
addressthe address value. It must be a valid address. Checksum can be included.
balanceThe balance associated of the address.
keyIndexThe key index of the address.
securityThe security level of the address.

◆ Address() [2/3]

IOTA::Models::Address::Address ( const char *  address,
const int64_t &  balance = 0,
const int32_t &  keyIndex = 0,
const int32_t &  security = 2,
const Type &  type = NORMAL 
)

Ctor, char* based to make implicitly convertion to Address more flexible.

Parameters
addressthe address value. It must be a valid address. Checksum can be included.
balanceThe balance associated of the address.
keyIndexThe key index of the address.
securityThe security level of the address.

◆ Address() [3/3]

IOTA::Models::Address::Address ( const Type &  type)
explicit

Ctor - mainly to used to build multisig addresses.

Parameters
typeThe address type, normal or multisig.

◆ ~Address()

IOTA::Models::Address::~Address ( )
default

Default dtor.

Member Function Documentation

◆ absorbDigests()

void IOTA::Models::Address::absorbDigests ( const std::vector< uint8_t > &  digests)

Multisig address related methods. Absorbs key digests Increments security according to digests.

Parameters
digestsThe key digests in bytes.

◆ empty()

bool IOTA::Models::Address::empty ( ) const
Returns
whether the address is empty or not.

◆ finalize()

void IOTA::Models::Address::finalize ( )

Finalizes and set the multisig address.

◆ getBalance()

const int64_t& IOTA::Models::Address::getBalance ( ) const
Returns
Balance.

◆ getChecksum()

const Types::Trytes& IOTA::Models::Address::getChecksum ( bool  validChecksum = false)

This function returns the address checksum. The returned checksum is generated the first time this function, or toTrytesWithChecksum, is called. If the object was built with an address containing a checksum, this checksum will be used even though it may be invalid, unless validChecksum is set to true.

Parameters
validChecksumif true, ensure the returned checksum is valid by regenerating it (see explanations above)
Returns
address checksum as trytes string.

◆ getKeyIndex()

const int32_t& IOTA::Models::Address::getKeyIndex ( ) const
Returns
Key Index.

◆ getSecurity()

const int32_t& IOTA::Models::Address::getSecurity ( ) const
Returns
Security.

◆ operator!=() [1/2]

bool IOTA::Models::Address::operator!= ( const Address rhs) const

Comparison operator.

Parameters
rhsother object to compare with.
Returns
Whether the two transactions are equal or not.

◆ operator!=() [2/2]

bool IOTA::Models::Address::operator!= ( const Types::Trytes &  rhs) const

Comparison operator, trytes-based for convenient use

Parameters
rhsother object to compare with.
Returns
Whether the two transactions are equal or not.

◆ operator==() [1/2]

bool IOTA::Models::Address::operator== ( const Address rhs) const

Comparison operator.

Parameters
rhsother object to compare with.
Returns
Whether the two transactions are equal or not.

◆ operator==() [2/2]

bool IOTA::Models::Address::operator== ( const Types::Trytes &  rhs) const

Comparison operator, trytes-based for convenient use

Parameters
rhsother object to compare with.
Returns
Whether the two transactions are equal or not.

◆ setAddress()

void IOTA::Models::Address::setAddress ( const Types::Trytes &  address)

Set the address value

Parameters
addressthe address value. It must be a valid address. Checksum can be included.

◆ setBalance()

void IOTA::Models::Address::setBalance ( const int64_t &  balance)
Parameters
balanceset new balance for input.

◆ setKeyIndex()

void IOTA::Models::Address::setKeyIndex ( const int32_t &  keyIndex)
Parameters
keyIndexset new keyIndex for input in transaction.

◆ setSecurity()

void IOTA::Models::Address::setSecurity ( const int32_t &  security)
Parameters
securityset new security level for input.

◆ toTrytes()

const Types::Trytes& IOTA::Models::Address::toTrytes ( ) const
Returns
address as a trytes string, without the checksum

◆ toTrytesWithChecksum()

Types::Trytes IOTA::Models::Address::toTrytesWithChecksum ( bool  validChecksum = false)

This function returns the address as a trytes string, including a checksum. The returned checksum is generated the first time this function, or getChecksum, is called. If the object was built with an address containing a checksum, this checksum will be used even though it may be invalid, unless validChecksum is set to true.

Parameters
validChecksumif true, ensure the returned checksum is valid by regenerating it (see explanations above)
Returns
address as a trytes string including a checksum.

◆ validate()

bool IOTA::Models::Address::validate ( const std::vector< std::vector< uint8_t >> &  digests)

Validates a generated multisig address.

Parameters
digestsThe keys digests.
Returns
whether the multisig address is valid or not.

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