Electroneum
Electroneum::WalletManager Struct Referenceabstract

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

#include <wallet2_api.h>

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

Static Public Member Functions

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...
 

Detailed Description

WalletManager - provides functions to manage wallets.

Definition at line 1017 of file wallet2_api.h.

Member Function Documentation

◆ blockchainHeight()

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

returns current blockchain height

Implemented in Electroneum::WalletManagerImpl.

◆ blockchainTargetHeight()

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

returns current blockchain target height

Implemented in Electroneum::WalletManagerImpl.

◆ blockTarget()

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

returns current block target

Implemented in Electroneum::WalletManagerImpl.

◆ checkUpdates()

std::tuple< bool, std::string, std::string, std::string, std::string > Electroneum::WalletManager::checkUpdates ( const std::string &  software,
std::string  subdir 
)
static

checks for an update and returns version, hash and url

Definition at line 348 of file wallet_manager.cpp.

349 {
350 #ifdef BUILD_TAG
351  static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
352 #else
353  static const char buildtag[] = "source";
354  // Override the subdir string when built from source
355  subdir = "source";
356 #endif
357 
359  MDEBUG("Checking for a new " << software << " version for " << buildtag);
360  if (!tools::check_updates(software, buildtag, version, hash))
361  return std::make_tuple(false, "", "", "", "");
362 
363  if (tools::vercmp(version.c_str(), ELECTRONEUM_VERSION) > 0)
364  {
365  std::string user_url = tools::get_update_url(software, subdir, buildtag, version, true);
366  std::string auto_url = tools::get_update_url(software, subdir, buildtag, version, false);
367  MGINFO("Version " << version << " of " << software << " for " << buildtag << " is available: " << user_url << ", SHA256 hash " << hash);
368  return std::make_tuple(true, version, hash, user_url, auto_url);
369  }
370  return std::make_tuple(false, "", "", "", "");
371 }
::std::string string
Definition: gtest-port.h:1097
std::string get_update_url(const std::string &software, const std::string &subdir, const std::string &buildtag, const std::string &version, bool user)
Definition: updates.cpp:101
#define MGINFO(x)
Definition: misc_log_ex.h:80
tuple make_tuple()
Definition: gtest-tuple.h:675
#define MDEBUG(x)
Definition: misc_log_ex.h:76
bool check_updates(const std::string &software, const std::string &buildtag, std::string &version, std::string &hash)
Definition: updates.cpp:41
const char *const ELECTRONEUM_VERSION
version
Supported socks variants.
Definition: socks.h:57
POD_CLASS hash
Definition: hash.h:50
int vercmp(const char *v0, const char *v1)
Definition: util.cpp:915
Here is the call graph for this function:

◆ closeWallet()

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

Here is the caller graph for this function:

◆ connected()

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

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

Implemented in Electroneum::WalletManagerImpl.

◆ createWallet() [1/2]

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

Here is the caller graph for this function:

◆ createWallet() [2/2]

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

Definition at line 1030 of file wallet2_api.h.

1031  {
1032  return createWallet(path, password, language, testnet ? TESTNET : MAINNET);
1033  }
virtual Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, NetworkType nettype, uint64_t kdf_rounds=1)=0
Creates new wallet.
Here is the call graph for this function:

◆ createWalletFromDevice()

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

Here is the caller graph for this function:

◆ createWalletFromKeys() [1/4]

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

Here is the caller graph for this function:

◆ createWalletFromKeys() [2/4]

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

Definition at line 1105 of file wallet2_api.h.

1113  {
1114  return createWalletFromKeys(path, password, language, testnet ? TESTNET : MAINNET, restoreHeight, addressString, viewKeyString, spendKeyString);
1115  }
virtual Wallet * 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)=0
recovers existing wallet using keys. Creates a view only wallet if spend key is omitted ...
Here is the call graph for this function:

◆ createWalletFromKeys() [3/4]

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

◆ createWalletFromKeys() [4/4]

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

Definition at line 1136 of file wallet2_api.h.

1143  {
1144  return createWalletFromKeys(path, language, testnet ? TESTNET : MAINNET, restoreHeight, addressString, viewKeyString, spendKeyString);
1145  }
virtual Wallet * 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)=0
recovers existing wallet using keys. Creates a view only wallet if spend key is omitted ...
Here is the call graph for this function:

◆ errorString()

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

returns verbose error string regarding last error;

Implemented in Electroneum::WalletManagerImpl.

◆ findWallets()

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

◆ isMining()

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

returns true iff mining

Implemented in Electroneum::WalletManagerImpl.

◆ miningHashRate()

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

returns current mining hash rate (0 if not mining)

Implemented in Electroneum::WalletManagerImpl.

◆ networkDifficulty()

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

returns current network difficulty

Implemented in Electroneum::WalletManagerImpl.

◆ openWallet() [1/2]

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

Here is the caller graph for this function:

◆ openWallet() [2/2]

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

Definition at line 1045 of file wallet2_api.h.

1046  {
1047  return openWallet(path, password, testnet ? TESTNET : MAINNET);
1048  }
virtual Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds=1, WalletListener *listener=nullptr)=0
Opens existing wallet.
Here is the call graph for this function:

◆ queryWalletDevice()

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

◆ recoveryWallet() [1/4]

virtual Wallet* Electroneum::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 
)
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
Returns
Wallet instance (Wallet::status() needs to be called to check if recovered successfully)

Implemented in Electroneum::WalletManagerImpl.

Here is the caller graph for this function:

◆ recoveryWallet() [2/4]

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

Definition at line 1062 of file wallet2_api.h.

1064  {
1065  return recoveryWallet(path, password, mnemonic, testnet ? TESTNET : MAINNET, restoreHeight);
1066  }
virtual Wallet * 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)=0
recovers existing wallet using mnemonic (electrum seed)
Here is the call graph for this function:

◆ recoveryWallet() [3/4]

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

◆ recoveryWallet() [4/4]

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

Definition at line 1078 of file wallet2_api.h.

1079  {
1080  return recoveryWallet(path, mnemonic, testnet ? TESTNET : MAINNET, restoreHeight);
1081  }
virtual Wallet * 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)=0
recovers existing wallet using mnemonic (electrum seed)
Here is the call graph for this function:

◆ resolveOpenAlias()

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

resolves an OpenAlias address to a electroneum address

Implemented in Electroneum::WalletManagerImpl.

◆ setDaemonAddress()

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

set the daemon address (hostname and port)

Implemented in Electroneum::WalletManagerImpl.

◆ startMining()

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

◆ stopMining()

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

stops mining

Implemented in Electroneum::WalletManagerImpl.

◆ verifyWalletPassword()

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

◆ walletExists()

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


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