Monero
Loading...
Searching...
No Matches
Monero::WalletManagerImpl Class Reference

#include <wallet_manager.h>

Inheritance diagram for Monero::WalletManagerImpl:
Collaboration diagram for Monero::WalletManagerImpl:

Public Member Functions

WalletcreateWallet (const std::string &path, const std::string &password, const std::string &language, NetworkType nettype, uint64_t kdf_rounds=1) override
 Creates new wallet.
WalletopenWallet (const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds=1, WalletListener *listener=nullptr) override
 Opens existing wallet.
virtual WalletrecoveryWallet (const std::string &path, const std::string &password, const std::string &mnemonic, NetworkType nettype, uint64_t restoreHeight, uint64_t kdf_rounds=1, const std::string &seed_offset={}) override
 recovers existing wallet using mnemonic (electrum seed)
virtual WalletcreateWalletFromKeys (const std::string &path, const std::string &password, const std::string &language, NetworkType nettype, uint64_t restoreHeight, const std::string &addressString, const std::string &viewKeyString, const std::string &spendKeyString="", uint64_t kdf_rounds=1) override
 recovers existing wallet using keys. Creates a view only wallet if spend key is omitted
virtual WalletrecoveryWallet (const std::string &path, const std::string &mnemonic, NetworkType nettype, uint64_t restoreHeight) override
 recovers existing wallet using mnemonic (electrum seed)
virtual WalletcreateWalletFromKeys (const std::string &path, const std::string &language, NetworkType nettype, uint64_t restoreHeight, const std::string &addressString, const std::string &viewKeyString, const std::string &spendKeyString="") override
 recovers existing wallet using keys. Creates a view only wallet if spend key is omitted
virtual WalletcreateWalletFromDevice (const std::string &path, const std::string &password, NetworkType nettype, const std::string &deviceName, uint64_t restoreHeight=0, const std::string &subaddressLookahead="", uint64_t kdf_rounds=1, WalletListener *listener=nullptr) override
 creates wallet using hardware device.
virtual bool closeWallet (Wallet *wallet, bool store=true) override
 Closes wallet. In case operation succeeded, wallet object deleted. in case operation failed, wallet object not deleted.
bool walletExists (const std::string &path) override
 TODO: delme walletExists - check if the given filename is the wallet.
bool verifyWalletPassword (const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds=1) const override
 verifyWalletPassword - check if the given filename is the wallet
bool queryWalletDevice (Wallet::Device &device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds=1) const override
 determine the key storage for the specified wallet file
std::vector< std::string > findWallets (const std::string &path) override
 findWallets - searches for the wallet files by given path name recursively
std::string errorString () const override
 returns verbose error string regarding last error;
void setDaemonAddress (const std::string &address) override
 set the daemon address (hostname and port)
bool connected (uint32_t *version=NULL) override
 returns whether the daemon can be reached, and its version number
uint64_t blockchainHeight () override
 returns current blockchain height
uint64_t blockchainTargetHeight () override
 returns current blockchain target height
uint64_t networkDifficulty () override
 returns current network difficulty
double miningHashRate () override
 returns current mining hash rate (0 if not mining)
uint64_t blockTarget () override
 returns current block target
bool isMining () override
 returns true iff mining
bool startMining (const std::string &address, uint32_t threads=1, bool background_mining=false, bool ignore_battery=true) override
 starts mining with the set number of threads
bool stopMining () override
 stops mining
std::string resolveOpenAlias (const std::string &address, bool &dnssec_valid) const override
 resolves an OpenAlias address to a monero address
bool setProxy (const std::string &address) override
 sets proxy address, empty string to disable
Public Member Functions inherited from Monero::WalletManager
WalletcreateWallet (const std::string &path, const std::string &password, const std::string &language, bool testnet=false)
WalletopenWallet (const std::string &path, const std::string &password, bool testnet=false)
WalletrecoveryWallet (const std::string &path, const std::string &password, const std::string &mnemonic, bool testnet=false, uint64_t restoreHeight=0)
WalletrecoveryWallet (const std::string &path, const std::string &mnemonic, bool testnet=false, uint64_t restoreHeight=0)
WalletcreateWalletFromKeys (const std::string &path, const std::string &password, const std::string &language, bool testnet, uint64_t restoreHeight, const std::string &addressString, const std::string &viewKeyString, const std::string &spendKeyString="")
WalletcreateWalletFromKeys (const std::string &path, const std::string &language, bool testnet, uint64_t restoreHeight, const std::string &addressString, const std::string &viewKeyString, const std::string &spendKeyString="")

Private Member Functions

 WalletManagerImpl ()

Private Attributes

net::http::client m_http_client
std::string m_errorString

Friends

struct WalletManagerFactory

Additional Inherited Members

Static Public Member Functions inherited from Monero::WalletManager
static std::tuple< bool, std::string, std::string, std::string, std::string > checkUpdates (const std::string &software, std::string subdir, const char *buildtag=nullptr, const char *current_version=nullptr)
 checks for an update and returns version, hash and url

Constructor & Destructor Documentation

◆ WalletManagerImpl()

Monero::WalletManagerImpl::WalletManagerImpl ( )
private

Member Function Documentation

◆ blockchainHeight()

uint64_t Monero::WalletManagerImpl::blockchainHeight ( )
overridevirtual

returns current blockchain height

Implements Monero::WalletManager.

◆ blockchainTargetHeight()

uint64_t Monero::WalletManagerImpl::blockchainTargetHeight ( )
overridevirtual

returns current blockchain target height

Implements Monero::WalletManager.

◆ blockTarget()

uint64_t Monero::WalletManagerImpl::blockTarget ( )
overridevirtual

returns current block target

Implements Monero::WalletManager.

◆ closeWallet()

bool Monero::WalletManagerImpl::closeWallet ( Wallet * wallet,
bool store = true )
overridevirtual

Closes wallet. In case operation succeeded, wallet object deleted. in case operation failed, wallet object not deleted.

Parameters
walletpreviously opened / created wallet instance
Returns
None

Implements Monero::WalletManager.

◆ connected()

bool Monero::WalletManagerImpl::connected ( uint32_t * version = NULL)
overridevirtual

returns whether the daemon can be reached, and its version number

Implements Monero::WalletManager.

◆ createWallet()

Wallet * Monero::WalletManagerImpl::createWallet ( const std::string & path,
const std::string & password,
const std::string & language,
NetworkType nettype,
uint64_t kdf_rounds = 1 )
overridevirtual

Creates new wallet.

Parameters
pathName of wallet file
passwordPassword of wallet file
languageLanguage to be used to generate electrum seed mnemonic
nettypeNetwork type
kdf_roundsNumber of rounds for key derivation function
Returns
Wallet instance (Wallet::status() needs to be called to check if created successfully)

Implements Monero::WalletManager.

◆ createWalletFromDevice()

Wallet * Monero::WalletManagerImpl::createWalletFromDevice ( const std::string & path,
const std::string & password,
NetworkType nettype,
const std::string & deviceName,
uint64_t restoreHeight = 0,
const std::string & subaddressLookahead = "",
uint64_t kdf_rounds = 1,
WalletListener * listener = nullptr )
overridevirtual

creates wallet using hardware device.

Parameters
pathName of wallet file to be created
passwordPassword of wallet file
nettypeNetwork type
deviceNameDevice name
restoreHeightrestore from start height (0 sets to current height)
subaddressLookaheadSize of subaddress lookahead (empty sets to some default low value)
kdf_roundsNumber of rounds for key derivation function
listenerWallet listener to set to the wallet after creation
Returns
Wallet instance (Wallet::status() needs to be called to check if recovered successfully)

Implements Monero::WalletManager.

◆ createWalletFromKeys() [1/2]

Wallet * Monero::WalletManagerImpl::createWalletFromKeys ( const std::string & path,
const std::string & language,
NetworkType nettype,
uint64_t restoreHeight,
const std::string & addressString,
const std::string & viewKeyString,
const std::string & spendKeyString = "" )
overridevirtual

recovers existing wallet using keys. Creates a view only wallet if spend key is omitted

Deprecated
this method creates a wallet WITHOUT a passphrase, use createWalletFromKeys(..., password, ...) instead
Parameters
pathName of wallet file to be created
languagelanguage
nettypeNetwork type
restoreHeightrestore from start height
addressStringpublic address
viewKeyStringview key
spendKeyStringspend key (optional)
Returns
Wallet instance (Wallet::status() needs to be called to check if recovered successfully)

Implements Monero::WalletManager.

◆ createWalletFromKeys() [2/2]

Wallet * Monero::WalletManagerImpl::createWalletFromKeys ( const std::string & path,
const std::string & password,
const std::string & language,
NetworkType nettype,
uint64_t restoreHeight,
const std::string & addressString,
const std::string & viewKeyString,
const std::string & spendKeyString = "",
uint64_t kdf_rounds = 1 )
overridevirtual

recovers existing wallet using keys. Creates a view only wallet if spend key is omitted

Parameters
pathName of wallet file to be created
passwordPassword of wallet file
languagelanguage
nettypeNetwork type
restoreHeightrestore from start height
addressStringpublic address
viewKeyStringview key
spendKeyStringspend key (optional)
kdf_roundsNumber of rounds for key derivation function
Returns
Wallet instance (Wallet::status() needs to be called to check if recovered successfully)

Implements Monero::WalletManager.

◆ errorString()

std::string Monero::WalletManagerImpl::errorString ( ) const
overridevirtual

returns verbose error string regarding last error;

Implements Monero::WalletManager.

◆ findWallets()

std::vector< std::string > Monero::WalletManagerImpl::findWallets ( const std::string & path)
overridevirtual

findWallets - searches for the wallet files by given path name recursively

Parameters
path- starting point to search
Returns
- list of strings with found wallets (absolute paths);

Implements Monero::WalletManager.

◆ isMining()

bool Monero::WalletManagerImpl::isMining ( )
overridevirtual

returns true iff mining

Implements Monero::WalletManager.

◆ miningHashRate()

double Monero::WalletManagerImpl::miningHashRate ( )
overridevirtual

returns current mining hash rate (0 if not mining)

Implements Monero::WalletManager.

◆ networkDifficulty()

uint64_t Monero::WalletManagerImpl::networkDifficulty ( )
overridevirtual

returns current network difficulty

Implements Monero::WalletManager.

◆ openWallet()

Wallet * Monero::WalletManagerImpl::openWallet ( const std::string & path,
const std::string & password,
NetworkType nettype,
uint64_t kdf_rounds = 1,
WalletListener * listener = nullptr )
overridevirtual

Opens existing wallet.

Parameters
pathName of wallet file
passwordPassword of wallet file
nettypeNetwork type
kdf_roundsNumber of rounds for key derivation function
listenerWallet listener to set to the wallet after creation
Returns
Wallet instance (Wallet::status() needs to be called to check if opened successfully)

Implements Monero::WalletManager.

◆ queryWalletDevice()

bool Monero::WalletManagerImpl::queryWalletDevice ( Wallet::Device & device_type,
const std::string & keys_file_name,
const std::string & password,
uint64_t kdf_rounds = 1 ) const
overridevirtual

determine the key storage for the specified wallet file

Parameters
device_type(OUT) wallet backend as enumerated in Wallet::Device
keys_file_nameKeys file to verify password for
passwordPassword to verify
Returns
true if password correct, else false

for verification only - determines key storage hardware

Implements Monero::WalletManager.

◆ recoveryWallet() [1/2]

Wallet * Monero::WalletManagerImpl::recoveryWallet ( const std::string & path,
const std::string & mnemonic,
NetworkType nettype,
uint64_t restoreHeight )
overridevirtual

recovers existing wallet using mnemonic (electrum seed)

Deprecated
this method creates a wallet WITHOUT a passphrase, use the alternate recoverWallet() method
Parameters
pathName of wallet file to be created
mnemonicmnemonic (25 words electrum seed)
nettypeNetwork type
restoreHeightrestore from start height
Returns
Wallet instance (Wallet::status() needs to be called to check if recovered successfully)

Implements Monero::WalletManager.

◆ recoveryWallet() [2/2]

Wallet * Monero::WalletManagerImpl::recoveryWallet ( const std::string & path,
const std::string & password,
const std::string & mnemonic,
NetworkType nettype,
uint64_t restoreHeight,
uint64_t kdf_rounds = 1,
const std::string & seed_offset = {} )
overridevirtual

recovers existing wallet using mnemonic (electrum seed)

Parameters
pathName of wallet file to be created
passwordPassword of wallet file
mnemonicmnemonic (25 words electrum seed)
nettypeNetwork type
restoreHeightrestore from start height
kdf_roundsNumber of rounds for key derivation function
seed_offsetSeed offset passphrase (optional)
Returns
Wallet instance (Wallet::status() needs to be called to check if recovered successfully)

Implements Monero::WalletManager.

◆ resolveOpenAlias()

std::string Monero::WalletManagerImpl::resolveOpenAlias ( const std::string & address,
bool & dnssec_valid ) const
overridevirtual

resolves an OpenAlias address to a monero address

Implements Monero::WalletManager.

◆ setDaemonAddress()

void Monero::WalletManagerImpl::setDaemonAddress ( const std::string & address)
overridevirtual

set the daemon address (hostname and port)

Implements Monero::WalletManager.

◆ setProxy()

bool Monero::WalletManagerImpl::setProxy ( const std::string & address)
overridevirtual

sets proxy address, empty string to disable

Implements Monero::WalletManager.

◆ startMining()

bool Monero::WalletManagerImpl::startMining ( const std::string & address,
uint32_t threads = 1,
bool background_mining = false,
bool ignore_battery = true )
overridevirtual

starts mining with the set number of threads

Implements Monero::WalletManager.

◆ stopMining()

bool Monero::WalletManagerImpl::stopMining ( )
overridevirtual

stops mining

Implements Monero::WalletManager.

◆ verifyWalletPassword()

bool Monero::WalletManagerImpl::verifyWalletPassword ( const std::string & keys_file_name,
const std::string & password,
bool no_spend_key,
uint64_t kdf_rounds = 1 ) const
overridevirtual

verifyWalletPassword - check if the given filename is the wallet

Parameters
keys_file_name- location of keys file
password- password to verify
no_spend_key- verify only view keys?
kdf_rounds- number of rounds for key derivation function
Returns
- true if password is correct
Note
This function will fail when the wallet keys file is opened because the wallet program locks the keys file. In this case, Wallet::unlockKeysFile() and Wallet::lockKeysFile() need to be called before and after the call to this function, respectively.

Implements Monero::WalletManager.

◆ walletExists()

bool Monero::WalletManagerImpl::walletExists ( const std::string & path)
overridevirtual

TODO: delme walletExists - check if the given filename is the wallet.

Parameters
path- filename
Returns
- true if wallet exists

Implements Monero::WalletManager.

◆ WalletManagerFactory

friend struct WalletManagerFactory
friend

Member Data Documentation

◆ m_errorString

std::string Monero::WalletManagerImpl::m_errorString
private

◆ m_http_client

net::http::client Monero::WalletManagerImpl::m_http_client
private

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