41 #include <boost/filesystem.hpp> 42 #include <boost/regex.hpp> 44 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY 45 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "WalletAPI" 57 wallet->
create(path, password, language);
69 wallet->
open(path, password);
89 addressString, viewKeyString, spendKeyString);
100 if(restoreHeight > 0){
103 wallet->
recover(path, password, mnemonic);
118 if(restoreHeight > 0){
140 if(restoreHeight > 0){
159 bool result = wallet_->
close(store);
170 bool keys_file_exists;
171 bool wallet_file_exists;
173 if(keys_file_exists){
194 std::vector<std::string> result;
195 boost::filesystem::path work_dir(path);
197 if(!boost::filesystem::is_directory(path)){
200 const boost::regex wallet_rx(
"(.*)\\.(keys)$");
201 boost::filesystem::recursive_directory_iterator end_itr;
202 for (boost::filesystem::recursive_directory_iterator itr(path); itr != end_itr; ++itr) {
204 if (!boost::filesystem::is_regular_file(itr->status()))
207 std::string filename = itr->path().filename().string();
211 bool matched = boost::regex_match(filename, what, wallet_rx);
214 std::string wallet_file = (itr->path().parent_path() /= what[1].str()).
string();
215 if (boost::filesystem::exists(wallet_file)) {
217 result.push_back(wallet_file);
226 return m_errorString;
243 req_t.
method =
"get_version";
269 return ires.target_height >= ires.height ? ires.target_height : ires.height;
279 return ires.difficulty;
321 mreq.threads_count = threads;
322 mreq.ignore_battery = ignore_battery;
323 mreq.do_background_mining = background_mining;
343 if (addresses.empty())
345 return addresses.front();
351 static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
353 static const char buildtag[] =
"source";
359 MDEBUG(
"Checking for a new " << software <<
" version for " << buildtag);
367 MGINFO(
"Version " <<
version <<
" of " << software <<
" for " << buildtag <<
" is available: " << user_url <<
", SHA256 hash " <<
hash);
380 if (!g_walletManager) {
384 return g_walletManager;
bool recoverFromDevice(const std::string &path, const std::string &password, const std::string &device_name)
bool set_server(const std::string &address, boost::optional< login > user, ssl_options_t ssl_options=ssl_support_t::e_ssl_support_autodetect)
bool create(const std::string &path, const std::string &password, const std::string &language)
static void setLogLevel(int level)
bool isMining() override
returns true iff mining
std::vector< std::string > findWallets(const std::string &path) override
findWallets - searches for the wallet files by given path name recursively
void setDaemonAddress(const std::string &address) override
set the daemon address (hostname and port)
bool is_connected(bool *ssl=NULL)
unsigned int g_test_dbg_lock_sleep
virtual Wallet * 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) override
creates wallet using hardware device.
bool walletExists(const std::string &path) override
TODO: delme walletExists - check if the given filename is the wallet.
epee::serialization::storage_entry id
bool close(bool store=true)
void mlog_set_log(const char *log)
virtual bool closeWallet(Wallet *wallet, bool store=true) override
Closes wallet. In case operation succeeded, wallet object deleted. in case operation failed...
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")
bool stopMining() override
stops 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
uint64_t blockchainHeight() override
returns current blockchain height
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
std::string errorString() const override
in case error status, returns error string
uint64_t blockchainTargetHeight() override
returns current blockchain target height
WalletManager - provides functions to manage wallets.
virtual void setListener(WalletListener *l) override
bool open(const std::string &path, const std::string &password)
virtual void onSetWallet(Wallet *wallet)
If the listener is created before the wallet this enables to set created wallet object.
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)
#define CORE_RPC_STATUS_OK
uint64_t estimateBlockChainHeight() const override
estimateBlockChainHeight - returns estimate blockchain height. More accurate than approximateBlockCha...
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
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
Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds=1, WalletListener *listener=nullptr) override
Opens existing 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
static WalletManager * getWalletManager()
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 ...
virtual AddressBook * addressBook() override
device & get_device(const std::string &device_descriptor)
bool recover(const std::string &path, const std::string &password, const std::string &seed)
unsigned __int64 uint64_t
const char *const ELECTRONEUM_VERSION
uint64_t blockTarget() override
returns current block target
double miningHashRate() override
returns current mining hash rate (0 if not mining)
version
Supported socks variants.
std::string resolveOpenAlias(const std::string &address, bool &dnssec_valid) const override
resolves an OpenAlias address to a electroneum address
void setRefreshFromBlockHeight(uint64_t refresh_from_block_height) override
setRefreshFromBlockHeight - start refresh from block height on recover
bool recoverFromKeysWithPassword(const std::string &path, const std::string &password, const std::string &language, const std::string &address_string, const std::string &viewkey_string, const std::string &spendkey_string="")
static void setLogCategories(const std::string &categories)
uint64_t networkDifficulty() override
returns current network difficulty
void setSubaddressLookahead(uint32_t major, uint32_t minor) override
setSubaddressLookahead - set size of subaddress lookahead
void mlog_set_log_level(int level)
Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, NetworkType nettype, uint64_t kdf_rounds=1) override
Creates new wallet.
bool connected(uint32_t *version=NULL) override
returns whether the daemon can be reached, and its version number
std::string errorString() const override
returns verbose error string regarding last error;
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.