Files
ObsidianDragon/src/wallet/lite_client_bridge.h
DanS 863d015628 feat(lite): lite wallet foundation (inherited working-tree state)
Preserve the previously-uncommitted lite wallet implementation and related dev WIP
under version control:
- src/wallet/ lite services: client bridge, bridge runtime, connection, lifecycle,
  sync, gateway, result parsers, state mapper, artifact contract/resolver, refresh
  services, UI adapters, wallet_backend/capabilities. (Includes two small M1 fixes:
  lifecycle walletReady now parses the response; default chain name -> "main".)
- src/chat/ chat protocol; tests/fixtures/ (lite + hushchat); tools/hushchat_fixture_check.cpp;
  scripts/build-lite-backend-artifact.sh.
- Pre-existing modified app_network/security/wizard, network_refresh_service, sidebar,
  mining_tab, bootstrap dialog, and version headers captured as-is.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 21:15:28 -05:00

84 lines
3.2 KiB
C++

// DragonX Wallet - ImGui Edition
// Copyright 2024-2026 The Hush Developers
// Released under the GPLv3
#pragma once
#include <string>
namespace dragonx {
namespace wallet {
struct LiteBridgeStringResult {
bool ok = false;
std::string value;
std::string error;
};
struct LiteClientBridgeApi {
using WalletExistsFn = bool (*)(const char* chainName);
using InitializeNewFn = char* (*)(bool dangerous, const char* server);
using InitializeNewFromPhraseFn = char* (*)(bool dangerous,
const char* server,
const char* seed,
unsigned long long birthday,
unsigned long long account,
bool overwrite);
using InitializeExistingFn = char* (*)(bool dangerous, const char* server);
using ExecuteFn = char* (*)(const char* command, const char* args);
using FreeStringFn = void (*)(char* value);
using CheckServerOnlineFn = bool (*)(const char* server);
using ShutdownFn = void (*)();
WalletExistsFn walletExists = nullptr;
InitializeNewFn initializeNew = nullptr;
InitializeNewFromPhraseFn initializeNewFromPhrase = nullptr;
InitializeExistingFn initializeExisting = nullptr;
ExecuteFn execute = nullptr;
FreeStringFn freeString = nullptr;
CheckServerOnlineFn checkServerOnline = nullptr;
ShutdownFn shutdown = nullptr;
};
class LiteClientBridge {
public:
static LiteClientBridge unavailable(std::string reason);
static LiteClientBridge fromApi(LiteClientBridgeApi api);
static LiteClientBridge linkedSdxl();
LiteClientBridge(const LiteClientBridge&) = delete;
LiteClientBridge& operator=(const LiteClientBridge&) = delete;
LiteClientBridge(LiteClientBridge&& other) noexcept;
LiteClientBridge& operator=(LiteClientBridge&& other) noexcept;
~LiteClientBridge();
bool available() const;
const std::string& unavailableReason() const { return unavailableReason_; }
bool walletExists(const std::string& chainName) const;
bool checkServerOnline(const std::string& server) const;
LiteBridgeStringResult initializeNew(bool dangerous, const std::string& server);
LiteBridgeStringResult initializeNewFromPhrase(bool dangerous,
const std::string& server,
const std::string& seed,
unsigned long long birthday,
unsigned long long account,
bool overwrite);
LiteBridgeStringResult initializeExisting(bool dangerous, const std::string& server);
LiteBridgeStringResult execute(const std::string& command, const std::string& args);
void shutdown();
private:
LiteClientBridge(LiteClientBridgeApi api, std::string unavailableReason);
LiteBridgeStringResult unavailableResult() const;
LiteBridgeStringResult takeOwnedString(char* rawValue) const;
LiteClientBridgeApi api_;
std::string unavailableReason_;
bool shutdownCalled_ = false;
};
} // namespace wallet
} // namespace dragonx