Monero
Loading...
Searching...
No Matches
Monero::WalletManager Struct Referenceabstract

WalletManager - provides functions to manage wallets. More...

#include <wallet2_api.h>

Inheritance diagram for Monero::WalletManager:

Public Member Functions

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

Static Public Member Functions

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

Detailed Description

WalletManager - provides functions to manage wallets.

Member Function Documentation

◆ blockchainHeight()

virtual uint64_t Monero::WalletManager::blockchainHeight ( )
pure virtual

returns current blockchain height

Implemented in Monero::WalletManagerImpl.

◆ blockchainTargetHeight()

virtual uint64_t Monero::WalletManager::blockchainTargetHeight ( )
pure virtual

returns current blockchain target height

Implemented in Monero::WalletManagerImpl.

◆ blockTarget()

virtual uint64_t Monero::WalletManager::blockTarget ( )
pure virtual

returns current block target

Implemented in Monero::WalletManagerImpl.

◆ checkUpdates()

std::tuple< bool, std::string, std::string, std::string, std::string > Monero::WalletManager::checkUpdates ( const std::string & software,
std::string subdir,
const char * buildtag = nullptr,
const char * current_version = nullptr )
static

checks for an update and returns version, hash and url

◆ closeWallet()

virtual bool Monero::WalletManager::closeWallet ( Wallet * wallet,
bool store = true )
pure virtual

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

Implemented in Monero::WalletManagerImpl.

◆ connected()

virtual bool Monero::WalletManager::connected ( uint32_t * version = NULL)
pure virtual

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

Implemented in Monero::WalletManagerImpl.

◆ createWallet() [1/2]

Wallet * Monero::WalletManager::createWallet ( const std::string & path,
const std::string & password,
const std::string & language,
bool testnet = false )
inline

◆ createWallet() [2/2]

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

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)

Implemented in Monero::WalletManagerImpl.

◆ createWalletFromDevice()

virtual Wallet * Monero::WalletManager::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 )
pure virtual

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)

Implemented in Monero::WalletManagerImpl.

◆ createWalletFromKeys() [1/4]

Wallet * Monero::WalletManager::createWalletFromKeys ( 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 = "" )
inline

◆ createWalletFromKeys() [2/4]

virtual Wallet * Monero::WalletManager::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 = "" )
pure virtual

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)

Implemented in Monero::WalletManagerImpl.

◆ createWalletFromKeys() [3/4]

Wallet * Monero::WalletManager::createWalletFromKeys ( 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 = "" )
inline

◆ createWalletFromKeys() [4/4]

virtual Wallet * Monero::WalletManager::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 )
pure virtual

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)

Implemented in Monero::WalletManagerImpl.

◆ errorString()

virtual std::string Monero::WalletManager::errorString ( ) const
pure virtual

returns verbose error string regarding last error;

Implemented in Monero::WalletManagerImpl.

◆ findWallets()

virtual std::vector< std::string > Monero::WalletManager::findWallets ( const std::string & path)
pure virtual

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);

Implemented in Monero::WalletManagerImpl.

◆ isMining()

virtual bool Monero::WalletManager::isMining ( )
pure virtual

returns true iff mining

Implemented in Monero::WalletManagerImpl.

◆ miningHashRate()

virtual double Monero::WalletManager::miningHashRate ( )
pure virtual

returns current mining hash rate (0 if not mining)

Implemented in Monero::WalletManagerImpl.

◆ networkDifficulty()

virtual uint64_t Monero::WalletManager::networkDifficulty ( )
pure virtual

returns current network difficulty

Implemented in Monero::WalletManagerImpl.

◆ openWallet() [1/2]

Wallet * Monero::WalletManager::openWallet ( const std::string & path,
const std::string & password,
bool testnet = false )
inline

◆ openWallet() [2/2]

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

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)

Implemented in Monero::WalletManagerImpl.

◆ queryWalletDevice()

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

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

Implemented in Monero::WalletManagerImpl.

◆ recoveryWallet() [1/4]

Wallet * Monero::WalletManager::recoveryWallet ( const std::string & path,
const std::string & mnemonic,
bool testnet = false,
uint64_t restoreHeight = 0 )
inline

◆ recoveryWallet() [2/4]

virtual Wallet * Monero::WalletManager::recoveryWallet ( const std::string & path,
const std::string & mnemonic,
NetworkType nettype,
uint64_t restoreHeight = 0 )
pure virtual

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)

Implemented in Monero::WalletManagerImpl.

◆ recoveryWallet() [3/4]

Wallet * Monero::WalletManager::recoveryWallet ( const std::string & path,
const std::string & password,
const std::string & mnemonic,
bool testnet = false,
uint64_t restoreHeight = 0 )
inline

◆ recoveryWallet() [4/4]

virtual Wallet * Monero::WalletManager::recoveryWallet ( const std::string & path,
const std::string & password,
const std::string & mnemonic,
NetworkType nettype = MAINNET,
uint64_t restoreHeight = 0,
uint64_t kdf_rounds = 1,
const std::string & seed_offset = {} )
pure virtual

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)

Implemented in Monero::WalletManagerImpl.

◆ resolveOpenAlias()

virtual std::string Monero::WalletManager::resolveOpenAlias ( const std::string & address,
bool & dnssec_valid ) const
pure virtual

resolves an OpenAlias address to a monero address

Implemented in Monero::WalletManagerImpl.

◆ setDaemonAddress()

virtual void Monero::WalletManager::setDaemonAddress ( const std::string & address)
pure virtual

set the daemon address (hostname and port)

Implemented in Monero::WalletManagerImpl.

◆ setProxy()

virtual bool Monero::WalletManager::setProxy ( const std::string & address)
pure virtual

sets proxy address, empty string to disable

Implemented in Monero::WalletManagerImpl.

◆ startMining()

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

starts mining with the set number of threads

Implemented in Monero::WalletManagerImpl.

◆ stopMining()

virtual bool Monero::WalletManager::stopMining ( )
pure virtual

stops mining

Implemented in Monero::WalletManagerImpl.

◆ verifyWalletPassword()

virtual bool Monero::WalletManager::verifyWalletPassword ( const std::string & keys_file_name,
const std::string & password,
bool no_spend_key,
uint64_t kdf_rounds = 1 ) const
pure virtual

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.

Implemented in Monero::WalletManagerImpl.

◆ walletExists()

virtual bool Monero::WalletManager::walletExists ( const std::string & path)
pure virtual

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

Parameters
path- filename
Returns
- true if wallet exists

Implemented in Monero::WalletManagerImpl.


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