Add the first user-visible HushChat surface: a Chat tab in the sidebar with a
two-pane, read-only conversation view — a conversation list on the left and the
selected thread on the right — reading from the App-owned ChatService store.
- New src/ui/windows/chat_tab.{h,cpp} (RenderChatTab(App*), mirroring the
Contacts tab). Conversations are sorted by most-recent activity; peer
z-addresses resolve to contact names via the address book when known; each
message shows sender + timestamp + wrapped body, with a contact-request tag
and a read-only footer (composing arrives in a later phase). Empty states
cover "wallet locked / identity not ready" and "no conversations yet".
- Sidebar wiring: NavPage::Chat + registry entry (static_assert stays balanced),
NavPageSurface + GetNavIconMD (ICON_MD_CHAT), dispatch in app.cpp, trace/sweep
page names, and App::chatService() accessor. The tab is gated on the new
WalletUiSurface::Chat, which returns DRAGONX_ENABLE_CHAT != 0 — so it only
appears in chat-enabled builds and is hidden (and unreachable) by default.
- i18n: English defaults for the chat nav label + hint strings.
Verified: Linux + Windows(mingw) build with chat ON, ctest 100%, hygiene clean;
caches restored to the OFF default. The screenshot sweep now includes the Chat
tab (sweepPageName "chat") for per-theme visual review.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
192 lines
5.2 KiB
C++
192 lines
5.2 KiB
C++
// DragonX Wallet - ImGui Edition
|
|
// Copyright 2024-2026 The Hush Developers
|
|
// Released under the GPLv3
|
|
|
|
#pragma once
|
|
|
|
#ifndef DRAGONX_LITE_BUILD
|
|
#define DRAGONX_LITE_BUILD 0
|
|
#endif
|
|
|
|
#ifndef DRAGONX_ENABLE_EMBEDDED_DAEMON
|
|
#define DRAGONX_ENABLE_EMBEDDED_DAEMON 1
|
|
#endif
|
|
|
|
#ifndef DRAGONX_ENABLE_LITE_BACKEND
|
|
#define DRAGONX_ENABLE_LITE_BACKEND 0
|
|
#endif
|
|
|
|
#ifndef DRAGONX_ENABLE_CHAT
|
|
#define DRAGONX_ENABLE_CHAT 0
|
|
#endif
|
|
|
|
namespace dragonx {
|
|
namespace wallet {
|
|
|
|
enum class WalletBuildKind {
|
|
FullNode,
|
|
Lite
|
|
};
|
|
|
|
enum class WalletBackendKind {
|
|
FullNodeRpc,
|
|
LiteClient
|
|
};
|
|
|
|
enum class WalletUiSurface {
|
|
Overview,
|
|
Send,
|
|
Receive,
|
|
History,
|
|
Contacts, // address book / chat roster; available in both variants (default: return true)
|
|
Chat, // HushChat conversations; gated on DRAGONX_ENABLE_CHAT (default OFF)
|
|
Mining,
|
|
Market,
|
|
Console,
|
|
Peers,
|
|
Explorer,
|
|
Settings,
|
|
BootstrapDownload,
|
|
SetupWizard,
|
|
NodeSettings,
|
|
LiteNetwork, // lite-wallet-only server browser (replaces Peers in lite builds)
|
|
LiteConsole // lite-wallet-only diagnostics console (full-node uses the RPC Console)
|
|
};
|
|
|
|
struct WalletCapabilities {
|
|
WalletBuildKind buildKind = WalletBuildKind::FullNode;
|
|
WalletBackendKind backendKind = WalletBackendKind::FullNodeRpc;
|
|
bool fullNodeRpcAvailable = true;
|
|
bool embeddedDaemonAvailable = true;
|
|
bool fullNodePagesAvailable = true;
|
|
bool fullNodeLifecycleActionsAvailable = true;
|
|
bool soloMiningAvailable = true;
|
|
bool poolMiningAvailable = true;
|
|
bool liteBackendAvailable = false;
|
|
bool lightwalletdNetworkAvailable = false;
|
|
bool liteWalletLifecycleAvailable = false;
|
|
bool liteWalletSyncAvailable = false;
|
|
bool liteWalletSendAvailable = false;
|
|
};
|
|
|
|
constexpr bool isLiteBuild(WalletBuildKind buildKind)
|
|
{
|
|
return buildKind == WalletBuildKind::Lite;
|
|
}
|
|
|
|
constexpr bool isLiteBuild(const WalletCapabilities& capabilities)
|
|
{
|
|
return isLiteBuild(capabilities.buildKind);
|
|
}
|
|
|
|
constexpr bool isFullNodeBuild(WalletBuildKind buildKind)
|
|
{
|
|
return buildKind == WalletBuildKind::FullNode;
|
|
}
|
|
|
|
constexpr WalletCapabilities makeWalletCapabilities(
|
|
WalletBuildKind buildKind,
|
|
bool embeddedDaemonCompiled,
|
|
bool liteBackendLinked)
|
|
{
|
|
const bool liteBuild = isLiteBuild(buildKind);
|
|
const bool fullNodeBuild = !liteBuild;
|
|
const bool liteBackendAvailable = liteBuild && liteBackendLinked;
|
|
|
|
return WalletCapabilities{
|
|
buildKind,
|
|
liteBuild ? WalletBackendKind::LiteClient : WalletBackendKind::FullNodeRpc,
|
|
fullNodeBuild,
|
|
fullNodeBuild && embeddedDaemonCompiled,
|
|
fullNodeBuild,
|
|
fullNodeBuild,
|
|
fullNodeBuild,
|
|
true,
|
|
liteBackendAvailable,
|
|
liteBackendAvailable,
|
|
liteBackendAvailable,
|
|
liteBackendAvailable,
|
|
liteBackendAvailable
|
|
};
|
|
}
|
|
|
|
constexpr WalletBuildKind currentWalletBuildKind()
|
|
{
|
|
return DRAGONX_LITE_BUILD ? WalletBuildKind::Lite : WalletBuildKind::FullNode;
|
|
}
|
|
|
|
constexpr WalletCapabilities currentWalletCapabilities()
|
|
{
|
|
return makeWalletCapabilities(
|
|
currentWalletBuildKind(),
|
|
DRAGONX_ENABLE_EMBEDDED_DAEMON != 0,
|
|
DRAGONX_ENABLE_LITE_BACKEND != 0);
|
|
}
|
|
|
|
constexpr bool supportsEmbeddedDaemon(const WalletCapabilities& capabilities)
|
|
{
|
|
return capabilities.embeddedDaemonAvailable;
|
|
}
|
|
|
|
constexpr bool supportsFullNodeLifecycleActions(const WalletCapabilities& capabilities)
|
|
{
|
|
return capabilities.fullNodeLifecycleActionsAvailable;
|
|
}
|
|
|
|
constexpr bool supportsSoloMining(const WalletCapabilities& capabilities)
|
|
{
|
|
return capabilities.soloMiningAvailable;
|
|
}
|
|
|
|
constexpr bool supportsPoolMining(const WalletCapabilities& capabilities)
|
|
{
|
|
return capabilities.poolMiningAvailable;
|
|
}
|
|
|
|
constexpr bool supportsLiteBackend(const WalletCapabilities& capabilities)
|
|
{
|
|
return capabilities.liteBackendAvailable;
|
|
}
|
|
|
|
constexpr bool supportsWalletDataBackend(const WalletCapabilities& capabilities)
|
|
{
|
|
return capabilities.fullNodeRpcAvailable || capabilities.liteWalletSyncAvailable;
|
|
}
|
|
|
|
constexpr bool isUiSurfaceAvailable(const WalletCapabilities& capabilities,
|
|
WalletUiSurface surface)
|
|
{
|
|
switch (surface) {
|
|
case WalletUiSurface::Console:
|
|
case WalletUiSurface::Peers:
|
|
case WalletUiSurface::Explorer:
|
|
return capabilities.fullNodePagesAvailable;
|
|
case WalletUiSurface::LiteNetwork:
|
|
case WalletUiSurface::LiteConsole:
|
|
return !capabilities.fullNodePagesAvailable; // lite builds only
|
|
case WalletUiSurface::Chat:
|
|
return DRAGONX_ENABLE_CHAT != 0; // experimental; compiled-in only when the feature is on
|
|
case WalletUiSurface::BootstrapDownload:
|
|
case WalletUiSurface::SetupWizard:
|
|
case WalletUiSurface::NodeSettings:
|
|
return capabilities.fullNodeLifecycleActionsAvailable;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
constexpr bool uiSurfaceNeedsWalletData(WalletUiSurface surface)
|
|
{
|
|
switch (surface) {
|
|
case WalletUiSurface::Overview:
|
|
case WalletUiSurface::Send:
|
|
case WalletUiSurface::Receive:
|
|
case WalletUiSurface::History:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
} // namespace wallet
|
|
} // namespace dragonx
|