Electroneum
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Electroneum::WalletManagerImpl Class Reference

#include <wallet_manager.h>

Inheritance diagram for Electroneum::WalletManagerImpl:
Inheritance graph
[legend]
Collaboration diagram for Electroneum::WalletManagerImpl:
Collaboration graph
[legend]

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. More...
 
WalletopenWallet (const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds=1, WalletListener *listener=nullptr) override
 Opens existing wallet. More...
 
virtual WalletrecoveryWallet (const std::string &path, const std::string &password, const std::string &mnemonic, NetworkType nettype, uint64_t restoreHeight, uint64_t kdf_rounds=1) override
 recovers existing wallet using mnemonic (electrum seed) More...
 
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 More...
 
virtual WalletrecoveryWallet (const std::string &path, const std::string &mnemonic, NetworkType nettype, uint64_t restoreHeight) override
 recovers existing wallet using mnemonic (electrum seed) More...
 
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 More...
 
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. More...
 
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. More...
 
bool walletExists (const std::string &path) override
 TODO: delme walletExists - check if the given filename is the wallet. More...
 
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 More...
 
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 More...
 
std::vector< std::string > findWallets (const std::string &path) override
 findWallets - searches for the wallet files by given path name recursively More...
 
std::string errorString () const override
 returns verbose error string regarding last error; More...
 
void setDaemonAddress (const std::string &address) override
 set the daemon address (hostname and port) More...
 
bool connected (uint32_t *version=NULL) override
 returns whether the daemon can be reached, and its version number More...
 
uint64_t blockchainHeight () override
 returns current blockchain height More...
 
uint64_t blockchainTargetHeight () override
 returns current blockchain target height More...
 
uint64_t networkDifficulty () override
 returns current network difficulty More...
 
double miningHashRate () override
 returns current mining hash rate (0 if not mining) More...
 
uint64_t blockTarget () override
 returns current block target More...
 
bool isMining () override
 returns true iff mining More...
 
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 More...
 
bool stopMining () override
 stops mining More...
 
std::string resolveOpenAlias (const std::string &address, bool &dnssec_valid) const override
 resolves an OpenAlias address to a electroneum address More...
 
- Public Member Functions inherited from Electroneum::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

std::string m_daemonAddress
 
epee::net_utils::http::http_simple_client m_http_client
 
std::string m_errorString
 

Friends

struct WalletManagerFactory
 

Additional Inherited Members

- Static Public Member Functions inherited from Electroneum::WalletManager
static std::tuple< bool, std::string, std::string, std::string, std::string > checkUpdates (const std::string &software, std::string subdir)
 checks for an update and returns version, hash and url More...
 

Constructor & Destructor Documentation

◆ WalletManagerImpl()

Electroneum::WalletManagerImpl::WalletManagerImpl ( )
inlineprivate

Member Function Documentation

◆ blockchainHeight()

uint64_t Electroneum::WalletManagerImpl::blockchainHeight ( )
overridevirtual

returns current blockchain height

Implements Electroneum::WalletManager.

◆ blockchainTargetHeight()

uint64_t Electroneum::WalletManagerImpl::blockchainTargetHeight ( )
overridevirtual

returns current blockchain target height

Implements Electroneum::WalletManager.

◆ blockTarget()

uint64_t Electroneum::WalletManagerImpl::blockTarget ( )
overridevirtual

returns current block target

Implements Electroneum::WalletManager.

◆ closeWallet()

bool Electroneum::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 Electroneum::WalletManager.

◆ connected()

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

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

Implements Electroneum::WalletManager.

◆ createWallet()

Wallet * Electroneum::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 Electroneum::WalletManager.

◆ createWalletFromDevice()

Wallet * Electroneum::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 Electroneum::WalletManager.

◆ createWalletFromKeys() [1/2]

Wallet * Electroneum::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 Electroneum::WalletManager.

◆ createWalletFromKeys() [2/2]

Wallet * Electroneum::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 Electroneum::WalletManager.

◆ errorString()

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

returns verbose error string regarding last error;

Implements Electroneum::WalletManager.

◆ findWallets()

std::vector< std::string > Electroneum::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 Electroneum::WalletManager.

◆ isMining()

bool Electroneum::WalletManagerImpl::isMining ( )
overridevirtual

returns true iff mining

Implements Electroneum::WalletManager.

◆ miningHashRate()

double Electroneum::WalletManagerImpl::miningHashRate ( )
overridevirtual

returns current mining hash rate (0 if not mining)

Implements Electroneum::WalletManager.

◆ networkDifficulty()

uint64_t Electroneum::WalletManagerImpl::networkDifficulty ( )
overridevirtual

returns current network difficulty

Implements Electroneum::WalletManager.

◆ openWallet()

Wallet * Electroneum::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 Electroneum::WalletManager.

◆ queryWalletDevice()

bool Electroneum::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 Electroneum::WalletManager.

◆ recoveryWallet() [1/2]

Wallet * Electroneum::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 Electroneum::WalletManager.

◆ recoveryWallet() [2/2]

Wallet * Electroneum::WalletManagerImpl::recoveryWallet ( const std::string &  path,
const std::string &  password,
const std::string &  mnemonic,
NetworkType  nettype,
uint64_t  restoreHeight,
uint64_t  kdf_rounds = 1 
)
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
Returns
Wallet instance (Wallet::status() needs to be called to check if recovered successfully)

Implements Electroneum::WalletManager.

◆ resolveOpenAlias()

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

resolves an OpenAlias address to a electroneum address

Implements Electroneum::WalletManager.

◆ setDaemonAddress()

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

set the daemon address (hostname and port)

Implements Electroneum::WalletManager.

◆ startMining()

bool Electroneum::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 Electroneum::WalletManager.

◆ stopMining()

bool Electroneum::WalletManagerImpl::stopMining ( )
overridevirtual

stops mining

Implements Electroneum::WalletManager.

◆ verifyWalletPassword()

bool Electroneum::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 Electroneum::WalletManager.

◆ walletExists()

bool Electroneum::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 Electroneum::WalletManager.

Friends And Related Function Documentation

◆ WalletManagerFactory

friend struct WalletManagerFactory
friend

Member Data Documentation

◆ m_daemonAddress

std::string Electroneum::WalletManagerImpl::m_daemonAddress
private

◆ m_errorString

std::string Electroneum::WalletManagerImpl::m_errorString
private

◆ m_http_client

epee::net_utils::http::http_simple_client Electroneum::WalletManagerImpl::m_http_client
private

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