Offline Transaction Signing (OTS) 0.1.0
Loading...
Searching...
No Matches
ots::Address Class Reference

Represents a Monero address. More...

#include <ots.hpp>

Collaboration diagram for ots::Address:

Public Member Functions

 Address (const std::string &address)
 create and check and monero address
 
const Network network () const noexcept
 Get the network of the address.
 
const AddressType type () const noexcept
 Get the type of the address.
 
virtual const std::string & fingerprint () const noexcept
 Generates a unique fingerprint for the Address.
 
bool isIntegrated () const noexcept
 Is it an integrated address An integrated address is a standard address with a payment ID.
 
std::string paymentID () const noexcept
 Get the payment ID of the address.
 
Address integratedAddress () const
 Get the standard address for an integrated address.
 
const size_t length () const noexcept
 character length of the base58 address
 
 operator std::string () const noexcept
 let you use the Address like it would be a std::string
 
 operator const std::string & () const noexcept
 let you use the Address like it would be a const std::string&
 
 operator const uint8_t * () const noexcept
 let you use the Address like it would be a uit8_t*
 
bool operator== (const Address &other) const noexcept
 Compare Address with another Address.
 
bool operator== (const std::string &other) const noexcept
 Compare Address with a std::string address.
 

Static Public Member Functions

static bool isValid (const std::string &address, const Network network=Network::MAIN) noexcept
 check if a given string is a valid monero address
 
static Network network (const std::string &address)
 check if a given string is a valid monero address
 
static AddressType type (const std::string &address)
 Get the type of the address.
 
static std::string fingerprint (const std::string &address)
 Generates a unique fingerprint for the Address.
 
static bool isIntegrated (const std::string &address)
 check if a given string is a valid monero address, and and integrated address
 
static std::string paymentID (const std::string &address, Network network=Network::MAIN)
 check if a given string is a valid monero address, and and integrated address
 
static std::string integratedAddress (const std::string &address, Network network=Network::MAIN)
 check if a given string is a valid monero address, and an integrated address
 

Protected Member Functions

 Address (const std::string &address, Network network)
 

Static Protected Member Functions

static Address validAddress (const std::string &address)
 

Protected Attributes

std::string m_address
 
Network m_network
 
AddressType m_type
 
std::string m_fingerprint
 

Detailed Description

Represents a Monero address.

todo: TODO: maybe implement later feather 14 words seed, too

Ensures valid Monero address and some insight of the address

Constructor & Destructor Documentation

◆ Address() [1/2]

ots::Address::Address ( const std::string &  address)
explicit

create and check and monero address

Parameters
addressthe base58 encoded address
Exceptions
ots::addressInvalidif not a valid monero address

◆ Address() [2/2]

ots::Address::Address ( const std::string &  address,
Network  network 
)
explicitprotected

Member Function Documentation

◆ fingerprint() [1/2]

const std::string & ots::Address::fingerprint ( ) const
virtualnoexcept

Generates a unique fingerprint for the Address.

Returns
std::string Address fingerprint
Note
Fingerprint is the last 6 digits of sha256(address) as upper case hex

◆ fingerprint() [2/2]

std::string ots::Address::fingerprint ( const std::string &  address)
static

Generates a unique fingerprint for the Address.

Parameters
addressthe base58 encoded address
Returns
std::string Address fingerprint
Exceptions
ots::exception::address::Invalidif not a valid monero address

◆ integratedAddress() [1/2]

Address ots::Address::integratedAddress ( ) const

Get the standard address for an integrated address.

Returns
Address standard address
Exceptions
ots::exception::address::NotIntegratedif the address is not integrated

◆ integratedAddress() [2/2]

std::string ots::Address::integratedAddress ( const std::string &  address,
Network  network = Network::MAIN 
)
static

check if a given string is a valid monero address, and an integrated address

Parameters
addressthe base58 encoded address
networkthe network the address should be valid for, default is MAIN
Returns
the base58 encoded integrated address
Exceptions
ots::exception::address::Invalidif not a valid monero address
ots::exception::address::NotIntegratedif the address is not an integrated address

◆ isIntegrated() [1/2]

bool ots::Address::isIntegrated ( ) const
noexcept

Is it an integrated address An integrated address is a standard address with a payment ID.

Returns
bool True if the address is integrated, false otherwise

◆ isIntegrated() [2/2]

bool ots::Address::isIntegrated ( const std::string &  address)
static

check if a given string is a valid monero address, and and integrated address

Parameters
addressthe base58 encoded address
Returns
true if an it is integrated address
Exceptions
ots::exception::address::Invalidif not a valid monero address

◆ isValid()

bool ots::Address::isValid ( const std::string &  address,
const Network  network = Network::MAIN 
)
staticnoexcept

check if a given string is a valid monero address

Parameters
addressthe base58 encoded address
networkthe network the address should be valid for
Returns
base58 address as std::string

◆ length()

const size_t ots::Address::length ( ) const
noexcept

character length of the base58 address

Returns
size_t length of the address

◆ network() [1/2]

const Network ots::Address::network ( ) const
noexcept

Get the network of the address.

Returns
the network type of the address

◆ network() [2/2]

Network ots::Address::network ( const std::string &  address)
static

check if a given string is a valid monero address

Parameters
addressthe base58 encoded address
Exceptions
ots::exception::address::Invalidif not a valid monero address
Returns
the network the address should be valid for

◆ operator const std::string &()

ots::Address::operator const std::string & ( ) const
noexcept

let you use the Address like it would be a const std::string&

Returns
base58 address as std::string

◆ operator const uint8_t *()

ots::Address::operator const uint8_t * ( ) const
noexcept

let you use the Address like it would be a uit8_t*

Returns
base58 address as uint8_t*

◆ operator std::string()

ots::Address::operator std::string ( ) const
explicitnoexcept

let you use the Address like it would be a std::string

Returns
base58 address as std::string

◆ operator==() [1/2]

bool ots::Address::operator== ( const Address other) const
noexcept

Compare Address with another Address.

Returns
bool True if the addresses are the same, false otherwise

◆ operator==() [2/2]

bool ots::Address::operator== ( const std::string &  other) const
noexcept

Compare Address with a std::string address.

Returns
bool True if the addresses are the same, false otherwise

◆ paymentID() [1/2]

std::string ots::Address::paymentID ( ) const
noexcept

Get the payment ID of the address.

Returns
std::string Payment ID or empty string if not integrated

◆ paymentID() [2/2]

std::string ots::Address::paymentID ( const std::string &  address,
Network  network = Network::MAIN 
)
static

check if a given string is a valid monero address, and and integrated address

Parameters
addressthe base58 encoded address
networkthe network the address should be valid for, default is MAIN
Returns
the payment ID of the address, if it is an integrated address, else an empty string
Exceptions
ots::exception::address::Invalidif not a valid monero address

◆ type() [1/2]

const AddressType ots::Address::type ( ) const
noexcept

Get the type of the address.

Returns
the type of the address

◆ type() [2/2]

AddressType ots::Address::type ( const std::string &  address)
static

Get the type of the address.

Parameters
addressthe base58 encoded address
Returns
the type of the address
Exceptions
ots::exception::address::Invalidif not a valid monero address

◆ validAddress()

static Address ots::Address::validAddress ( const std::string &  address)
staticprotected

Member Data Documentation

◆ m_address

std::string ots::Address::m_address
protected

◆ m_fingerprint

std::string ots::Address::m_fingerprint
mutableprotected

◆ m_network

Network ots::Address::m_network
protected

◆ m_type

AddressType ots::Address::m_type
protected

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