Skip to main content

qualia_core_db/net/
nym_adapter.rs

1//! Nym mixnet adapter surface for core-db.
2//!
3//! Historical demo/mock path removed. Live enable/bind lives in
4//! `qualia_client_core::nym_live` (official `nym-sdk`). This module keeps the
5//! config shape and fails closed unless a real client reports live.
6
7use serde::{Deserialize, Serialize};
8
9#[derive(Serialize, Deserialize, Debug, Clone)]
10pub struct NymConfig {
11    /// When true, prefer sandbox (default). Production uses mainnet + credentials.
12    pub is_demo_mode: bool,
13    pub mixnet_proxy_port: u16,
14    pub active_network: String,
15}
16
17impl Default for NymConfig {
18    fn default() -> Self {
19        Self {
20            is_demo_mode: true,
21            mixnet_proxy_port: 1080,
22            active_network: "sandbox".to_string(),
23        }
24    }
25}
26
27/// Former mock initializer — no longer simulates a SOCKS5 bind.
28/// Callers must use `qualia_client_core::nym_live::enable_nym` for a real client.
29pub async fn initialize_nym_proxy(config: &NymConfig) -> Result<(), String> {
30    Err(format!(
31        "nym_adapter::initialize_nym_proxy is not a live bind (network={}). \
32         Use Wallet/Settings enable → qualia_client_core::nym_live (nym-sdk).",
33        config.active_network
34    ))
35}
36
37/// Former mock Sphinx dispatch — fails closed. Real routing is a follow-up once
38/// the mixnet client is live and claimed.
39pub async fn route_through_mixnet(_payload: &[u8]) -> Result<Vec<u8>, String> {
40    Err("nym_adapter::route_through_mixnet has no live path — \
41         mixnet client claim+bind required (no simulated MIXNET_RESPONSE_OK)"
42        .into())
43}