Files
ObsidianDragon/src/rpc/connection.h
DanS 40dd6d45b2 daemon version check, idle mining control, bootstrap mirror, import key paste, and cleanup
- Add startup binary version checking for dragonxd/xmrig
- Display daemon version in UI
- Add idle mining thread count adjustment
- Add bootstrap mirror option (bootstrap2.dragonx.is) in setup wizard
- Add paste button to import private key dialog with address validation
- Add z-address generation UI feedback (loading indicator)
- Add option to delete blockchain data while preserving wallet.dat
- Add font scale slider hotkey tooltip (Ctrl+Plus/Ctrl+Minus)
- Fix Windows RPC auth: trim \r from config values, add .cookie fallback
- Fix connection status message during block index loading
- Improve application shutdown to prevent lingering background process
2026-03-17 14:57:12 -05:00

104 lines
2.6 KiB
C++

// DragonX Wallet - ImGui Edition
// Copyright 2024-2026 The Hush Developers
// Released under the GPLv3
#pragma once
#include <string>
namespace dragonx {
namespace rpc {
/**
* @brief Connection configuration
*/
struct ConnectionConfig {
std::string host = "127.0.0.1";
std::string port = "21769";
std::string rpcuser;
std::string rpcpassword;
std::string hush_dir;
std::string proxy; // SOCKS5 proxy for Tor
bool use_embedded = true;
};
/**
* @brief Manages connection to dragonxd
*
* Handles auto-detection of DRAGONX.conf, starting embedded daemon,
* and connection lifecycle.
*/
class Connection {
public:
Connection();
~Connection();
/**
* @brief Auto-detect and load connection config
* @return Config from DRAGONX.conf or defaults
*/
static ConnectionConfig autoDetectConfig();
/**
* @brief Get the default DRAGONX.conf location
*/
static std::string getDefaultConfPath();
/**
* @brief Get the default DragonX data directory
*/
static std::string getDefaultDataDir();
/**
* @brief Parse a DRAGONX.conf file
* @param path Path to conf file
* @return Parsed configuration
*/
static ConnectionConfig parseConfFile(const std::string& path);
/**
* @brief Check if Sapling params exist
*/
static bool verifySaplingParams();
/**
* @brief Get the Sapling params directory
*/
static std::string getSaplingParamsDir();
/**
* @brief Create a default DRAGONX.conf file
* @param path Path to create the file
* @return true if created successfully
*/
static bool createDefaultConfig(const std::string& path);
/**
* @brief Ensure exportdir is set in DRAGONX.conf
* @param confPath Path to the conf file
* @return true if exportdir exists or was added
*/
static bool ensureExportDir(const std::string& confPath);
/**
* @brief Ensure wallet encryption flags are set in DRAGONX.conf
* @param confPath Path to the conf file
* @return true if flags exist or were added
*/
static bool ensureEncryptionEnabled(const std::string& confPath);
/**
* @brief Try to read .cookie auth file from the data directory
* @param dataDir Path to the daemon data directory
* @param user Output: cookie username (__cookie__)
* @param password Output: cookie password
* @return true if cookie file was read successfully
*/
static bool readAuthCookie(const std::string& dataDir, std::string& user, std::string& password);
private:
};
} // namespace rpc
} // namespace dragonx