feat: use and expose persistent path exposed by using LogosModuleContext

This commit is contained in:
Khushboo Mehta
2026-08-19 22:11:39 +02:00
parent cd47b9e137
commit e2bb1ad2f9
3 changed files with 32 additions and 3 deletions
+9 -1
View File
@@ -283,6 +283,14 @@ std::string LEZCoreModule::version() const {
return "0.3.0";
}
// === Wallet Location ===
std::string LEZCoreModule::wallet_dir() {
if (!isContextReady() || instancePersistencePath().empty())
return LEZ_NO_WALLET_DIR;
return instancePersistencePath();
}
// === Account Management ===
std::string LEZCoreModule::create_account_public() {
@@ -1334,4 +1342,4 @@ std::vector<std::string> LEZCoreModule::get_all_labels_for_account(const std::st
}
return result;
}
}
+5 -2
View File
@@ -5,11 +5,14 @@
#include <string>
#include <logos_json.h>
#include <logos_module_context.h>
extern "C" {
#include <wallet_ffi.h>
}
constexpr const char* LEZ_NO_WALLET_DIR = "-";
// Universal (Qt-free) execution-zone core module. The Qt glue (provider
// object + plugin) is generated from this header by logos-cpp-generator, which
// maps the std return types below to the Qt signatures callers invoke:
@@ -18,7 +21,7 @@ extern "C" {
// NOTE: the generator parses this header line-by-line and only recognises a
// method when its declaration ends with ';' on a single line. Keep every
// method declaration on ONE line — multi-line signatures are silently dropped.
class LEZCoreModule {
class LEZCoreModule : public LogosModuleContext {
public:
LEZCoreModule();
~LEZCoreModule();
@@ -28,8 +31,8 @@ public:
std::string name() const;
std::string version() const;
std::string wallet_dir();
// === Wallet Lifecycle ===
std::string create_new(const std::string& config_path, const std::string& storage_path, const std::string& statistics_path, const std::string& password);
int64_t open(const std::string& config_path, const std::string& storage_path, const std::string& statistics_path);
int64_t save();
+18
View File
@@ -32,6 +32,24 @@ LOGOS_TEST(name_and_version) {
LOGOS_ASSERT_EQ(module.version(), std::string("0.3.0"));
}
// ============================================================================
// Wallet location
// ============================================================================
// Constructed directly, so no host has stamped a persistence path onto it. It
// must say so rather than invent one: a caller that receives a plausible-looking
// path here would write a wallet somewhere the host does not manage and will
// never clean up.
// Never "" -- that answer is reserved for a call that never arrived, so a caller
// can tell "no directory here" from "I could not reach you" and retry instead of
// writing a wallet somewhere it invented.
LOGOS_TEST(wallet_dir_reports_no_directory_without_a_provisioning_host) {
LEZCoreModule module;
LOGOS_ASSERT(!module.isContextReady());
LOGOS_ASSERT_EQ(module.wallet_dir(), std::string(LEZ_NO_WALLET_DIR));
LOGOS_ASSERT(!module.wallet_dir().empty());
}
// ============================================================================
// Account management
// ============================================================================