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>
93 lines
2.1 KiB
C++
93 lines
2.1 KiB
C++
// DragonX Wallet - ImGui Edition
|
|
// Copyright 2024-2026 The Hush Developers
|
|
// Released under the GPLv3
|
|
|
|
#pragma once
|
|
|
|
#include "wallet_capabilities.h"
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace dragonx {
|
|
namespace wallet {
|
|
|
|
enum class WalletBackendState {
|
|
Unavailable,
|
|
Disconnected,
|
|
Connecting,
|
|
Syncing,
|
|
Ready,
|
|
Error
|
|
};
|
|
|
|
struct WalletBackendStatus {
|
|
WalletBackendState state = WalletBackendState::Unavailable;
|
|
std::string message;
|
|
std::optional<int> walletHeight;
|
|
std::optional<int> chainHeight;
|
|
double syncProgress = 0.0;
|
|
};
|
|
|
|
struct WalletBackendResult {
|
|
bool ok = false;
|
|
std::string error;
|
|
};
|
|
|
|
struct WalletOpenRequest {
|
|
std::string walletPath;
|
|
std::string serverUrl;
|
|
bool restoreFromSeed = false;
|
|
};
|
|
|
|
struct WalletSendRequest {
|
|
std::string fromAddress;
|
|
std::string toAddress;
|
|
double amount = 0.0;
|
|
double fee = 0.0;
|
|
std::string memo;
|
|
};
|
|
|
|
struct WalletSendResult {
|
|
bool accepted = false;
|
|
std::string txid;
|
|
std::string error;
|
|
};
|
|
|
|
class WalletBackend {
|
|
public:
|
|
virtual ~WalletBackend() = default;
|
|
|
|
virtual WalletBackendKind kind() const = 0;
|
|
virtual WalletCapabilities capabilities() const = 0;
|
|
virtual WalletBackendStatus status() const = 0;
|
|
};
|
|
|
|
class FullNodeWalletBackend : public WalletBackend {
|
|
public:
|
|
~FullNodeWalletBackend() override = default;
|
|
};
|
|
|
|
class LiteWalletBackend : public WalletBackend {
|
|
public:
|
|
~LiteWalletBackend() override = default;
|
|
|
|
virtual WalletBackendResult setServer(const std::string& serverUrl) = 0;
|
|
virtual WalletBackendResult openWallet(const WalletOpenRequest& request) = 0;
|
|
virtual WalletBackendResult startSync() = 0;
|
|
virtual WalletBackendResult cancelSync() = 0;
|
|
virtual WalletSendResult sendTransaction(const WalletSendRequest& request) = 0;
|
|
};
|
|
|
|
class WalletBackendRouter {
|
|
public:
|
|
virtual ~WalletBackendRouter() = default;
|
|
|
|
virtual WalletBackend& activeBackend() = 0;
|
|
virtual const WalletBackend& activeBackend() const = 0;
|
|
};
|
|
|
|
} // namespace wallet
|
|
} // namespace dragonx
|