Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/lez_core_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -1334,4 +1342,4 @@ std::vector<std::string> LEZCoreModule::get_all_labels_for_account(const std::st
}

return result;
}
}
7 changes: 5 additions & 2 deletions src/lez_core_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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();
Expand All @@ -28,8 +31,8 @@ class LEZCoreModule {

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();
Expand Down
18 changes: 18 additions & 0 deletions tests/test_lez_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ============================================================================
Expand Down
Loading