feat: blockchain rescan via daemon restart + status bar progress
- Fix z_importwallet to use full path instead of filename only - Add rescanBlockchain() method that restarts daemon with -rescan flag - Track rescan progress via daemon output parsing and getrescaninfo RPC - Display rescan progress in status bar with animated indicator when starting - Improve dark theme card contrast: lighter surface-variant, tinted borders, stronger rim-light
This commit is contained in:
@@ -158,6 +158,10 @@ ConnectionConfig Connection::autoDetectConfig()
|
||||
std::string conf_path = getDefaultConfPath();
|
||||
|
||||
if (fs::exists(conf_path)) {
|
||||
// Ensure exportdir is present in existing config
|
||||
ensureExportDir(conf_path);
|
||||
// Ensure encryption flags are present
|
||||
ensureEncryptionEnabled(conf_path);
|
||||
config = parseConfFile(conf_path);
|
||||
config.hush_dir = data_dir;
|
||||
} else {
|
||||
@@ -203,6 +207,9 @@ bool Connection::createDefaultConfig(const std::string& path)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the data directory for exportdir
|
||||
std::string dataDir = getDefaultDataDir();
|
||||
|
||||
file << "# DragonX configuration file\n";
|
||||
file << "# Auto-generated by DragonX Wallet\n";
|
||||
file << "\n";
|
||||
@@ -211,6 +218,9 @@ bool Connection::createDefaultConfig(const std::string& path)
|
||||
file << "rpcport=" << DRAGONX_DEFAULT_RPC_PORT << "\n";
|
||||
file << "server=1\n";
|
||||
file << "txindex=1\n";
|
||||
file << "exportdir=" << dataDir << "\n";
|
||||
file << "experimentalfeatures=1\n";
|
||||
file << "developerencryptwallet=1\n";
|
||||
file << "addnode=195.201.20.230\n";
|
||||
file << "addnode=195.201.137.219\n";
|
||||
|
||||
@@ -220,5 +230,94 @@ bool Connection::createDefaultConfig(const std::string& path)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Connection::ensureExportDir(const std::string& confPath)
|
||||
{
|
||||
// Read existing config and check if exportdir is present
|
||||
std::ifstream inFile(confPath);
|
||||
if (!inFile.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string contents;
|
||||
std::string line;
|
||||
bool hasExportDir = false;
|
||||
|
||||
while (std::getline(inFile, line)) {
|
||||
contents += line + "\n";
|
||||
// Check for exportdir (case insensitive check for key)
|
||||
if (line.find("exportdir=") == 0 || line.find("exportdir =") == 0) {
|
||||
hasExportDir = true;
|
||||
}
|
||||
}
|
||||
inFile.close();
|
||||
|
||||
if (hasExportDir) {
|
||||
return true; // Already has exportdir
|
||||
}
|
||||
|
||||
// Append exportdir to config
|
||||
std::ofstream outFile(confPath, std::ios::app);
|
||||
if (!outFile.is_open()) {
|
||||
DEBUG_LOGF("Failed to open config for appending exportdir: %s\n", confPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string dataDir = getDefaultDataDir();
|
||||
outFile << "\n# Export directory for wallet backups (required for z_exportwallet)\n";
|
||||
outFile << "exportdir=" << dataDir << "\n";
|
||||
outFile.close();
|
||||
|
||||
DEBUG_LOGF("Added exportdir to config: %s\n", confPath.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Connection::ensureEncryptionEnabled(const std::string& confPath)
|
||||
{
|
||||
// Read existing config and check if encryption flags are present
|
||||
std::ifstream inFile(confPath);
|
||||
if (!inFile.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string contents;
|
||||
std::string line;
|
||||
bool hasExperimental = false;
|
||||
bool hasEncrypt = false;
|
||||
|
||||
while (std::getline(inFile, line)) {
|
||||
contents += line + "\n";
|
||||
if (line.find("experimentalfeatures=") == 0 || line.find("experimentalfeatures =") == 0) {
|
||||
hasExperimental = true;
|
||||
}
|
||||
if (line.find("developerencryptwallet=") == 0 || line.find("developerencryptwallet =") == 0) {
|
||||
hasEncrypt = true;
|
||||
}
|
||||
}
|
||||
inFile.close();
|
||||
|
||||
if (hasExperimental && hasEncrypt) {
|
||||
return true; // Already has both flags
|
||||
}
|
||||
|
||||
// Append missing flags to config
|
||||
std::ofstream outFile(confPath, std::ios::app);
|
||||
if (!outFile.is_open()) {
|
||||
DEBUG_LOGF("Failed to open config for appending encryption flags: %s\n", confPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
outFile << "\n# Enable wallet encryption support\n";
|
||||
if (!hasExperimental) {
|
||||
outFile << "experimentalfeatures=1\n";
|
||||
}
|
||||
if (!hasEncrypt) {
|
||||
outFile << "developerencryptwallet=1\n";
|
||||
}
|
||||
outFile.close();
|
||||
|
||||
DEBUG_LOGF("Added encryption flags to config: %s\n", confPath.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace rpc
|
||||
} // namespace dragonx
|
||||
|
||||
@@ -73,6 +73,20 @@ public:
|
||||
*/
|
||||
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);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user