iota.lib.cpp
IOTA C++ Library
|
#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 |
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.
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.
address | the address value. It must be a valid address. Checksum can be included. |
balance | The balance associated of the address. |
keyIndex | The key index of the address. |
security | The security level of the address. |
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.
address | the address value. It must be a valid address. Checksum can be included. |
balance | The balance associated of the address. |
keyIndex | The key index of the address. |
security | The security level of the address. |
|
explicit |
Ctor - mainly to used to build multisig addresses.
type | The address type, normal or multisig. |
|
default |
Default dtor.
void IOTA::Models::Address::absorbDigests | ( | const std::vector< uint8_t > & | digests | ) |
Multisig address related methods. Absorbs key digests Increments security according to digests.
digests | The key digests in bytes. |
bool IOTA::Models::Address::empty | ( | ) | const |
void IOTA::Models::Address::finalize | ( | ) |
Finalizes and set the multisig address.
const int64_t& IOTA::Models::Address::getBalance | ( | ) | const |
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.
validChecksum | if true, ensure the returned checksum is valid by regenerating it (see explanations above) |
const int32_t& IOTA::Models::Address::getKeyIndex | ( | ) | const |
const int32_t& IOTA::Models::Address::getSecurity | ( | ) | const |
bool IOTA::Models::Address::operator!= | ( | const Address & | rhs | ) | const |
Comparison operator.
rhs | other object to compare with. |
bool IOTA::Models::Address::operator!= | ( | const Types::Trytes & | rhs | ) | const |
Comparison operator, trytes-based for convenient use
rhs | other object to compare with. |
bool IOTA::Models::Address::operator== | ( | const Address & | rhs | ) | const |
Comparison operator.
rhs | other object to compare with. |
bool IOTA::Models::Address::operator== | ( | const Types::Trytes & | rhs | ) | const |
Comparison operator, trytes-based for convenient use
rhs | other object to compare with. |
void IOTA::Models::Address::setAddress | ( | const Types::Trytes & | address | ) |
Set the address value
address | the address value. It must be a valid address. Checksum can be included. |
void IOTA::Models::Address::setBalance | ( | const int64_t & | balance | ) |
balance | set new balance for input. |
void IOTA::Models::Address::setKeyIndex | ( | const int32_t & | keyIndex | ) |
keyIndex | set new keyIndex for input in transaction. |
void IOTA::Models::Address::setSecurity | ( | const int32_t & | security | ) |
security | set new security level for input. |
const Types::Trytes& IOTA::Models::Address::toTrytes | ( | ) | const |
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.
validChecksum | if true, ensure the returned checksum is valid by regenerating it (see explanations above) |
bool IOTA::Models::Address::validate | ( | const std::vector< std::vector< uint8_t >> & | digests | ) |
Validates a generated multisig address.
digests | The keys digests. |