diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index d49100f1..5fbd09a3 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -32,16 +32,21 @@ std::atomic glogs_initialized(false); namespace plain_wallet { + std::string get_bundle_root_dir() + { + char buffer[1000] = {0}; + strcpy(buffer, getenv("HOME")); + return buffer; + } + void initialize_logs() { - char buffer[1000] = {}; - strcpy(buffer, getenv("HOME")); - std::string log_dir = buffer; + std::string log_dir = get_bundle_root_dir(); log_dir += "/Documents"; epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2); epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); epee::log_space::log_singletone::add_logger(LOGGER_FILE, "plain_wallet.log", log_dir.c_str()); - LOG_PRINT_L0("Plain wallet initialized: " << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG); + LOG_PRINT_L0("Plain wallet initialized: " << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG << ", log location: " << log_dir + "/plain_wallet.log"); glogs_initialized = true; } @@ -51,6 +56,24 @@ namespace plain_wallet return PROJECT_VERSION_LONG; } + struct strings_list + { + std::list items; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(items) + END_KV_SERIALIZE_MAP() + + }; + + std::string get_wallet_files() + { + std::string wallet_files_path = get_bundle_root_dir() + "/Documents"; + strings_list sl = AUTO_VAL_INIT(sl); + epee::file_io_utils::get_folder_content(wallet_files_path, sl.items, true); + return epee::serialization::store_t_to_json(sl); + } + hwallet create_instance(const std::string& ip, const std::string& port) { if (!glogs_initialized) diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h index dd481299..0b9bb92a 100644 --- a/src/wallet/plain_wallet_api.h +++ b/src/wallet/plain_wallet_api.h @@ -13,6 +13,7 @@ namespace plain_wallet hwallet create_instance(const std::string& ip, const std::string& port); void destroy_instance(hwallet h); std::string get_version(); + std::string get_wallet_files(); std::string open(hwallet h, const std::string& path, const std::string& password); std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string& password);