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

holds monero internal account and internal functions More...

#include <account.hpp>

Public Member Functions

 Account (const std::array< unsigned char, 32 > &key, const Network network)
 Construct a new Monero Account object.
 
 Account (const crypto::secret_key &key, const Network network)
 Construct a new Monero Account object.
 
 Account (const KeyStore &key, const Network network)
 Construct a new Monero Account object.
 
 Account (const cryptonote::account_base &account, const Network network)
 Construct a new Monero Account object.
 
 Account (const Account &account)
 Construct a new Monero Account object.
 
Address address () const noexcept
 the public address of the wallet/account(0)
 
Address address (uint32_t account, uint32_t index) const noexcept
 address of a certain account and index
 
Address address (const cryptonote::subaddress_index index) const noexcept
 address of a certain subaddr_index
 
bool hasAddress (const Address &address, uint32_t maxAccountDepth=DEFAULT_MAX_ACCOUNT_DEPTH, uint32_t maxIndexDepth=DEFAULT_MAX_INDEX_DEPTH) const noexcept
 check if the address is in the wallet, but restricted to the search depth
 
std::pair< uint32_t, uint32_t > addressIndex (const Address &address, uint32_t maxAccountDepth=DEFAULT_MAX_ACCOUNT_DEPTH, uint32_t maxIndexDepth=DEFAULT_MAX_INDEX_DEPTH) const
 get the account and subindex of a address in the Wallet
 
WipeableString secretSpendKey () const noexcept
 secret spend key of the wallet in hex digits
 
WipeableString publicSpendKey () const noexcept
 public spend key of the wallet in hex digits
 
WipeableString secretViewKey () const noexcept
 secret view key of the wallet in hex digits
 
WipeableString publicViewKey () const noexcept
 public view key of the wallet in hex digits
 
void clearAddressCache () const noexcept
 clear the address cache
 
size_t importOutputs (const std::string &outputs)
 import outputs from a string
 
size_t importOutputs (const std::tuple< uint64_t, uint64_t, std::vector< exported_transfer_details > > &outputs)
 import outputs from a tuple
 
size_t importOutputs (const std::tuple< uint64_t, uint64_t, std::vector< transfer_details > > &outputs)
 import outputs from a tuple
 
std::string signData (const std::string &data) const
 sign a message with the wallet
 
std::string signData (const std::string &data, const std::pair< uint32_t, uint32_t > &index) const
 sign a message with subindex address of the wallet
 
std::string signData (const std::string &data, const std::string &address, uint32_t maxAccountDepth=DEFAULT_MAX_ACCOUNT_DEPTH, uint32_t maxIndexDepth=DEFAULT_MAX_INDEX_DEPTH) const
 sign a message with the provided address of the wallet
 
std::string signData (const std::string &data, const Address &address, uint32_t maxAccountDepth=DEFAULT_MAX_ACCOUNT_DEPTH, uint32_t maxIndexDepth=DEFAULT_MAX_INDEX_DEPTH) const
 sign a message with the provided address of the wallet
 

Static Public Member Functions

static bool verifyData (const std::string &data, const Address &address, const std::string &signature)
 verify a signed message
 
static bool verifyData (const std::string &data, const std::string &address, const std::string &signature)
 verify a signed message
 
static bool verifyDataLegacy (const std::string &data, const Address &address, const std::string &signature)
 verify a signed message
 
static bool verifyDataLegacy (const std::string &data, const std::string &address, const std::string &signature)
 verify a signed message
 

Detailed Description

holds monero internal account and internal functions

Constructor & Destructor Documentation

◆ Account() [1/5]

ots::Account::Account ( const std::array< unsigned char, 32 > &  key,
const Network  network 
)
explicit

Construct a new Monero Account object.

Parameters
keyis the secret spend key
networkis the network type

◆ Account() [2/5]

ots::Account::Account ( const crypto::secret_key &  key,
const Network  network 
)
explicit

Construct a new Monero Account object.

Parameters
keyis the secret spend key, crypto::secret_key is a monero secure container for the key
networkis the network type

◆ Account() [3/5]

ots::Account::Account ( const KeyStore key,
const Network  network 
)
explicit

Construct a new Monero Account object.

Parameters
keyis the secret spend key, KeyStore is the secure container for the secret spend key
networkis the network type

◆ Account() [4/5]

ots::Account::Account ( const cryptonote::account_base &  account,
const Network  network 
)
explicit

Construct a new Monero Account object.

Parameters
accountis the account object, account_base is the monero secure container for the account
networkis the network type

◆ Account() [5/5]

ots::Account::Account ( const Account account)
explicit

Construct a new Monero Account object.

Parameters
accountis the account object, it simply duplicates the account from another Account object

Member Function Documentation

◆ address() [1/3]

Address ots::Account::address ( ) const
noexcept

the public address of the wallet/account(0)

Returns
Address the public address

◆ address() [2/3]

Address ots::Account::address ( const cryptonote::subaddress_index  index) const
noexcept

address of a certain subaddr_index

◆ address() [3/3]

Address ots::Account::address ( uint32_t  account,
uint32_t  index 
) const
noexcept

address of a certain account and index

Parameters
accountthe account

◆ addressIndex()

std::pair< uint32_t, uint32_t > ots::Account::addressIndex ( const Address address,
uint32_t  maxAccountDepth = DEFAULT_MAX_ACCOUNT_DEPTH,
uint32_t  maxIndexDepth = DEFAULT_MAX_INDEX_DEPTH 
) const

get the account and subindex of a address in the Wallet

Parameters
addressthe address to check
maxAccountDepththe maximum account depth to search
maxIndexDepththe maximum index depth to search
Returns
first number is the account, second number the index
Exceptions
ots::exception::address:NotFoundif the address is not in the wallet

◆ clearAddressCache()

void ots::Account::clearAddressCache ( ) const
noexcept

clear the address cache

◆ hasAddress()

bool ots::Account::hasAddress ( const Address address,
uint32_t  maxAccountDepth = DEFAULT_MAX_ACCOUNT_DEPTH,
uint32_t  maxIndexDepth = DEFAULT_MAX_INDEX_DEPTH 
) const
noexcept

check if the address is in the wallet, but restricted to the search depth

Parameters
addressthe address to check
maxAccountDepththe maximum account depth to search
maxIndexDepththe maximum index depth to search
Returns
bool true if the address is in the wallet, false otherwise

◆ importOutputs() [1/3]

size_t ots::Account::importOutputs ( const std::string &  outputs)

import outputs from a string

Parameters
outputsthe outputs to import
Returns
the number of outputs imported
Exceptions
ots::exception::wallet::ImportOutputsif the magic is bad or the data is bad
Note
not finished yet, still need to hunt some things down and understand the complete transplanted code from wallet2
Todo:
TODO: continue here to make it work

◆ importOutputs() [2/3]

size_t ots::Account::importOutputs ( const std::tuple< uint64_t, uint64_t, std::vector< exported_transfer_details > > &  outputs)

import outputs from a tuple

Parameters
outputsthe outputs to import
Returns
the number of outputs imported
Todo:
TODO: clarify the tuple format

◆ importOutputs() [3/3]

size_t ots::Account::importOutputs ( const std::tuple< uint64_t, uint64_t, std::vector< transfer_details > > &  outputs)

import outputs from a tuple

Parameters
outputsthe outputs to import
Returns
the number of outputs imported
Todo:
TODO: clarify the tuple format

◆ publicSpendKey()

WipeableString ots::Account::publicSpendKey ( ) const
noexcept

public spend key of the wallet in hex digits

◆ publicViewKey()

WipeableString ots::Account::publicViewKey ( ) const
noexcept

public view key of the wallet in hex digits

◆ secretSpendKey()

WipeableString ots::Account::secretSpendKey ( ) const
noexcept

secret spend key of the wallet in hex digits

◆ secretViewKey()

WipeableString ots::Account::secretViewKey ( ) const
noexcept

secret view key of the wallet in hex digits

◆ signData() [1/4]

std::string ots::Account::signData ( const std::string &  data) const

sign a message with the wallet

Parameters
datathe message to sign
Returns
the signature of the message
Exceptions
ots::exception::BufferOverflowExceptionif tools:write_varint fails in Account::hashData() (should not happen)

◆ signData() [2/4]

std::string ots::Account::signData ( const std::string &  data,
const Address address,
uint32_t  maxAccountDepth = DEFAULT_MAX_ACCOUNT_DEPTH,
uint32_t  maxIndexDepth = DEFAULT_MAX_INDEX_DEPTH 
) const

sign a message with the provided address of the wallet

Parameters
datathe message to sign
addressthe address of the wallet
maxAccountDepththe maximum account depth to search
maxIndexDepththe maximum index depth to search
Returns
the signature of the message
Exceptions
ots::exception::address::Invalidif the address is not valid
ots::exception::BufferOverflowExceptionif tools:write_varint fails in Account::hashData() (should not happen)

◆ signData() [3/4]

std::string ots::Account::signData ( const std::string &  data,
const std::pair< uint32_t, uint32_t > &  index 
) const

sign a message with subindex address of the wallet

Parameters
datathe message to sign
indexthe account and index to sign with
Returns
the signature of the message
Exceptions
ots::exception::BufferOverflowExceptionif tools:write_varint fails in Account::hashData() (should not happen)

◆ signData() [4/4]

std::string ots::Account::signData ( const std::string &  data,
const std::string &  address,
uint32_t  maxAccountDepth = DEFAULT_MAX_ACCOUNT_DEPTH,
uint32_t  maxIndexDepth = DEFAULT_MAX_INDEX_DEPTH 
) const

sign a message with the provided address of the wallet

Parameters
datathe message to sign
addressthe address of the wallet
maxAccountDepththe maximum account depth to search
maxIndexDepththe maximum index depth to search
Returns
the signature of the message
Exceptions
ots::exception::address::Invalidif the address is not valid
ots::exception::BufferOverflowExceptionif tools:write_varint fails in Account::hashData() (should not happen)

◆ verifyData() [1/2]

bool ots::Account::verifyData ( const std::string &  data,
const Address address,
const std::string &  signature 
)
static

verify a signed message

Parameters
datathe message to verify
addressof the signer
signatureof the message
Returns
true if the signature is valid
Note
the signature must be a base58 encoded string
will only verify signatures of Version 2 and only mode 0 (signed with secret spend key)

◆ verifyData() [2/2]

bool ots::Account::verifyData ( const std::string &  data,
const std::string &  address,
const std::string &  signature 
)
static

verify a signed message

Parameters
datathe message to verify
addressof the signer
signatureof the message
Returns
true if the signature is valid
Note
the signature must be a base58 encoded string
will only verify signatures of Version 2 and only mode 0 (signed with secret spend key)

◆ verifyDataLegacy() [1/2]

bool ots::Account::verifyDataLegacy ( const std::string &  data,
const Address address,
const std::string &  signature 
)
static

verify a signed message

Parameters
datathe message to verify
addressof the signer
signatureof the message
Returns
true if the signature is valid
Note
the signature must be a base58 encoded string
will only verify signatures of Version 1 and only mode 0 (signed with secret spend key)

◆ verifyDataLegacy() [2/2]

bool ots::Account::verifyDataLegacy ( const std::string &  data,
const std::string &  address,
const std::string &  signature 
)
static

verify a signed message

Parameters
datathe message to verify
addressof the signer
signatureof the message
Returns
true if the signature is valid
Note
the signature must be a base58 encoded string
will only verify signatures of Version 1 and only mode 0 (signed with secret spend key)

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