forked from lthn/blockchain
added wallets list api
This commit is contained in:
parent
47ef958d7e
commit
6ff8669843
2 changed files with 28 additions and 4 deletions
|
|
@ -32,16 +32,21 @@ std::atomic<bool> 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<std::string> 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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue