Electroneum
Electroneum::WalletManagerImpl Class Reference

#include <wallet_manager.h>

Inheritance diagram for Electroneum::WalletManagerImpl:
Collaboration diagram for Electroneum::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. 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="")
 

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

Detailed Description

Definition at line 39 of file wallet_manager.h.

Member Function Documentation

◆ blockchainHeight()

uint64_t Electroneum::WalletManagerImpl::blockchainHeight ( )
overridevirtual

returns current blockchain height

Implements Electroneum::WalletManager.

Definition at line 252 of file wallet_manager.cpp.

253 {
256 
257  if (!epee::net_utils::invoke_http_json("/getinfo", ireq, ires, m_http_client))
258  return 0;
259  return ires.height;
260 }
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
Here is the call graph for this function:

◆ blockchainTargetHeight()

uint64_t Electroneum::WalletManagerImpl::blockchainTargetHeight ( )
overridevirtual

returns current blockchain target height

Implements Electroneum::WalletManager.

Definition at line 262 of file wallet_manager.cpp.

263 {
266 
267  if (!epee::net_utils::invoke_http_json("/getinfo", ireq, ires, m_http_client))
268  return 0;
269  return ires.target_height >= ires.height ? ires.target_height : ires.height;
270 }
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
Here is the call graph for this function:

◆ blockTarget()

uint64_t Electroneum::WalletManagerImpl::blockTarget ( )
overridevirtual

returns current block target

Implements Electroneum::WalletManager.

Definition at line 295 of file wallet_manager.cpp.

296 {
299 
300  if (!epee::net_utils::invoke_http_json("/getinfo", ireq, ires, m_http_client))
301  return 0;
302  return ires.target;
303 }
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
Here is the call graph for this function:

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

Definition at line 154 of file wallet_manager.cpp.

155 {
156  WalletImpl * wallet_ = dynamic_cast<WalletImpl*>(wallet);
157  if (!wallet_)
158  return false;
159  bool result = wallet_->close(store);
160  if (!result) {
161  m_errorString = wallet_->errorString();
162  } else {
163  delete wallet_;
164  }
165  return result;
166 }
Here is the call graph for this function:

◆ connected()

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

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

Implements Electroneum::WalletManager.

Definition at line 237 of file wallet_manager.cpp.

238 {
241  req_t.jsonrpc = "2.0";
243  req_t.method = "get_version";
244  if (!epee::net_utils::invoke_http_json("/json_rpc", req_t, resp_t, m_http_client))
245  return false;
246 
247  if (version)
248  *version = resp_t.result.version;
249  return true;
250 }
epee::serialization::storage_entry id
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
boost::variant< uint64_t, uint32_t, uint16_t, uint8_t, int64_t, int32_t, int16_t, int8_t, double, bool, std::string, section, array_entry > storage_entry
version
Supported socks variants.
Definition: socks.h:57
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
Here is the call graph for this function:

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

Definition at line 53 of file wallet_manager.cpp.

55 {
56  WalletImpl * wallet = new WalletImpl(nettype, kdf_rounds);
57  wallet->create(path, password, language);
58  return wallet;
59 }
Here is the call graph for this function:

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

Definition at line 125 of file wallet_manager.cpp.

133 {
134  WalletImpl * wallet = new WalletImpl(nettype, kdf_rounds);
135  wallet->setListener(listener);
136  if (listener){
137  listener->onSetWallet(wallet);
138  }
139 
140  if(restoreHeight > 0){
141  wallet->setRefreshFromBlockHeight(restoreHeight);
142  } else {
143  wallet->setRefreshFromBlockHeight(wallet->estimateBlockChainHeight());
144  }
145  auto lookahead = tools::parse_subaddress_lookahead(subaddressLookahead);
146  if (lookahead)
147  {
148  wallet->setSubaddressLookahead(lookahead->first, lookahead->second);
149  }
150  wallet->recoverFromDevice(path, password, deviceName);
151  return wallet;
152 }
boost::optional< std::pair< uint32_t, uint32_t > > parse_subaddress_lookahead(const std::string &str)
Definition: util.cpp:977
Here is the call graph for this function:

◆ createWalletFromKeys() [1/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.

Definition at line 107 of file wallet_manager.cpp.

116 {
117  WalletImpl * wallet = new WalletImpl(nettype, kdf_rounds);
118  if(restoreHeight > 0){
119  wallet->setRefreshFromBlockHeight(restoreHeight);
120  }
121  wallet->recoverFromKeysWithPassword(path, password, language, addressString, viewKeyString, spendKeyString);
122  return wallet;
123 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createWalletFromKeys() [2/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.

Definition at line 80 of file wallet_manager.cpp.

87 {
88  return createWalletFromKeys(path, "", language, nettype, restoreHeight,
89  addressString, viewKeyString, spendKeyString);
90 }
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) override
recovers existing wallet using keys. Creates a view only wallet if spend key is omitted ...
Here is the call graph for this function:

◆ errorString()

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

returns verbose error string regarding last error;

Implements Electroneum::WalletManager.

Definition at line 224 of file wallet_manager.cpp.

225 {
226  return m_errorString;
227 }

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

Definition at line 192 of file wallet_manager.cpp.

193 {
194  std::vector<std::string> result;
195  boost::filesystem::path work_dir(path);
196  // return empty result if path doesn't exist
197  if(!boost::filesystem::is_directory(path)){
198  return result;
199  }
200  const boost::regex wallet_rx("(.*)\\.(keys)$"); // searching for <wallet_name>.keys files
201  boost::filesystem::recursive_directory_iterator end_itr; // Default ctor yields past-the-end
202  for (boost::filesystem::recursive_directory_iterator itr(path); itr != end_itr; ++itr) {
203  // Skip if not a file
204  if (!boost::filesystem::is_regular_file(itr->status()))
205  continue;
206  boost::smatch what;
207  std::string filename = itr->path().filename().string();
208 
209  LOG_PRINT_L3("Checking filename: " << filename);
210 
211  bool matched = boost::regex_match(filename, what, wallet_rx);
212  if (matched) {
213  // if keys file found, checking if there's wallet file itself
214  std::string wallet_file = (itr->path().parent_path() /= what[1].str()).string();
215  if (boost::filesystem::exists(wallet_file)) {
216  LOG_PRINT_L3("Found wallet: " << wallet_file);
217  result.push_back(wallet_file);
218  }
219  }
220  }
221  return result;
222 }
::std::string string
Definition: gtest-port.h:1097
#define LOG_PRINT_L3(x)
Definition: misc_log_ex.h:102

◆ isMining()

bool Electroneum::WalletManagerImpl::isMining ( )
overridevirtual

returns true iff mining

Implements Electroneum::WalletManager.

Definition at line 305 of file wallet_manager.cpp.

306 {
309 
310  if (!epee::net_utils::invoke_http_json("/mining_status", mreq, mres, m_http_client))
311  return false;
312  return mres.active;
313 }
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
Here is the call graph for this function:

◆ miningHashRate()

double Electroneum::WalletManagerImpl::miningHashRate ( )
overridevirtual

returns current mining hash rate (0 if not mining)

Implements Electroneum::WalletManager.

Definition at line 282 of file wallet_manager.cpp.

283 {
286 
288  if (!epee::net_utils::invoke_http_json("/mining_status", mreq, mres, m_http_client))
289  return 0.0;
290  if (!mres.active)
291  return 0.0;
292  return mres.speed;
293 }
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
Here is the call graph for this function:

◆ networkDifficulty()

uint64_t Electroneum::WalletManagerImpl::networkDifficulty ( )
overridevirtual

returns current network difficulty

Implements Electroneum::WalletManager.

Definition at line 272 of file wallet_manager.cpp.

273 {
276 
277  if (!epee::net_utils::invoke_http_json("/getinfo", ireq, ires, m_http_client))
278  return 0;
279  return ires.difficulty;
280 }
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
Here is the call graph for this function:

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

Definition at line 61 of file wallet_manager.cpp.

62 {
63  WalletImpl * wallet = new WalletImpl(nettype, kdf_rounds);
64  wallet->setListener(listener);
65  if (listener){
66  listener->onSetWallet(wallet);
67  }
68 
69  wallet->open(path, password);
70  //Refresh addressBook
71  wallet->addressBook()->refresh();
72  return wallet;
73 }
Here is the call graph for this function:

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

Definition at line 184 of file wallet_manager.cpp.

185 {
187  bool r = tools::wallet2::query_device(type, keys_file_name, password, kdf_rounds);
188  device_type = static_cast<Wallet::Device>(type);
189  return r;
190 }
static bool query_device(hw::device::device_type &device_type, const std::string &keys_file_name, const epee::wipeable_string &password, uint64_t kdf_rounds=1)
determine the key storage for the specified wallet file
Definition: wallet2.cpp:4807
Here is the call graph for this function:

◆ recoveryWallet() [1/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.

Definition at line 92 of file wallet_manager.cpp.

98 {
99  WalletImpl * wallet = new WalletImpl(nettype, kdf_rounds);
100  if(restoreHeight > 0){
101  wallet->setRefreshFromBlockHeight(restoreHeight);
102  }
103  wallet->recover(path, password, mnemonic);
104  return wallet;
105 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recoveryWallet() [2/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.

Definition at line 75 of file wallet_manager.cpp.

76 {
77  return recoveryWallet(path, "", mnemonic, nettype, restoreHeight);
78 }
virtual Wallet * recoveryWallet(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)
Here is the call graph for this function:

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

Definition at line 340 of file wallet_manager.cpp.

341 {
342  std::vector<std::string> addresses = tools::dns_utils::addresses_from_url(address, dnssec_valid);
343  if (addresses.empty())
344  return "";
345  return addresses.front();
346 }
std::vector< std::string > addresses_from_url(const std::string &url, bool &dnssec_valid)
gets a electroneum address from the TXT record of a DNS entry
Definition: dns_utils.cpp:452
const char * address
Definition: multisig.cpp:37
Here is the call graph for this function:

◆ setDaemonAddress()

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

set the daemon address (hostname and port)

Implements Electroneum::WalletManager.

Definition at line 229 of file wallet_manager.cpp.

230 {
231  m_daemonAddress = address;
232  if(m_http_client.is_connected())
233  m_http_client.disconnect();
234  m_http_client.set_server(address, boost::none);
235 }
bool set_server(const std::string &address, boost::optional< login > user, ssl_options_t ssl_options=ssl_support_t::e_ssl_support_autodetect)
Definition: http_client.h:302
const char * address
Definition: multisig.cpp:37
Here is the call graph for this function:

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

Definition at line 315 of file wallet_manager.cpp.

316 {
319 
320  mreq.miner_address = address;
321  mreq.threads_count = threads;
322  mreq.ignore_battery = ignore_battery;
323  mreq.do_background_mining = background_mining;
324 
325  if (!epee::net_utils::invoke_http_json("/start_mining", mreq, mres, m_http_client))
326  return false;
327  return mres.status == CORE_RPC_STATUS_OK;
328 }
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
#define CORE_RPC_STATUS_OK
const char * address
Definition: multisig.cpp:37
Here is the call graph for this function:

◆ stopMining()

bool Electroneum::WalletManagerImpl::stopMining ( )
overridevirtual

stops mining

Implements Electroneum::WalletManager.

Definition at line 330 of file wallet_manager.cpp.

331 {
334 
335  if (!epee::net_utils::invoke_http_json("/stop_mining", mreq, mres, m_http_client))
336  return false;
337  return mres.status == CORE_RPC_STATUS_OK;
338 }
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
#define CORE_RPC_STATUS_OK
Here is the call graph for this function:

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

Definition at line 179 of file wallet_manager.cpp.

180 {
181  return tools::wallet2::verify_password(keys_file_name, password, no_spend_key, hw::get_device("default"), kdf_rounds);
182 }
device & get_device(const std::string &device_descriptor)
Definition: device.cpp:95
static bool verify_password(const std::string &keys_file_name, const epee::wipeable_string &password, bool no_spend_key, hw::device &hwdev, uint64_t kdf_rounds)
verify password for specified wallet keys file.
Definition: wallet2.cpp:4699
Here is the call graph for this function:

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

Definition at line 168 of file wallet_manager.cpp.

169 {
170  bool keys_file_exists;
171  bool wallet_file_exists;
172  tools::wallet2::wallet_exists(path, keys_file_exists, wallet_file_exists);
173  if(keys_file_exists){
174  return true;
175  }
176  return false;
177 }
static void wallet_exists(const std::string &file_path, bool &keys_file_exists, bool &wallet_file_exists)
Check if wallet keys and bin files exist.
Definition: wallet2.cpp:5697
Here is the call graph for this function:

Friends And Related Function Documentation

◆ WalletManagerFactory

friend struct WalletManagerFactory
friend

Definition at line 98 of file wallet_manager.h.


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