Files
ObsidianDragon/src/services/wallet_security_workflow.cpp
DanS 9edab31728 Refactor app services and stabilize refresh/UI flows
- Add refresh scheduler and network refresh service boundaries for typed
  refresh results, ordered RPC collectors, applicators, and price parsing.
- Add daemon lifecycle and wallet security workflow helpers while preserving
  App-owned command RPC, decrypt, cancellation, and UI handoff behavior.
- Split balance, console, mining, amount formatting, and async task logic into
  focused modules with expanded Phase 4 test coverage.
- Fix market price loading by triggering price refresh immediately, avoiding
  queue-pressure drops, tracking loading/error state, and adding translations.
- Polish send, explorer, peers, settings, theme/schema, and related tab UI.
- Replace checked-in generated language headers with build-generated resources.
- Document the cleanup audit, UI static-state guidance, and architecture updates.
2026-04-29 12:47:57 -05:00

115 lines
3.4 KiB
C++

#include "wallet_security_workflow.h"
#include <utility>
namespace dragonx {
namespace services {
void WalletSecurityWorkflow::reset()
{
state_ = {};
}
void WalletSecurityWorkflow::start(std::chrono::steady_clock::time_point now)
{
state_.phase = DecryptPhase::Working;
state_.step = DecryptStep::Unlock;
state_.status = stepStatus(DecryptStep::Unlock);
state_.inProgress = true;
state_.stepStarted = now;
state_.overallStarted = now;
}
void WalletSecurityWorkflow::advanceTo(DecryptStep step, std::string status,
std::chrono::steady_clock::time_point now)
{
state_.phase = DecryptPhase::Working;
state_.step = step;
state_.status = std::move(status);
state_.inProgress = true;
state_.stepStarted = now;
}
void WalletSecurityWorkflow::failEntry(std::string status)
{
state_.phase = DecryptPhase::PassphraseEntry;
state_.step = DecryptStep::Unlock;
state_.status = std::move(status);
state_.inProgress = false;
}
void WalletSecurityWorkflow::fail(std::string status)
{
state_.phase = DecryptPhase::Error;
state_.status = std::move(status);
state_.inProgress = false;
}
void WalletSecurityWorkflow::closeDialogForImport()
{
state_.inProgress = false;
state_.importActive = true;
}
void WalletSecurityWorkflow::finishImport()
{
state_.importActive = false;
}
WalletSecurityWorkflow::WalletFilePlan WalletSecurityWorkflow::planWalletFiles(
const std::string& dataDir,
std::uint64_t timestampSeconds)
{
WalletFilePlan plan;
plan.dataDir = dataDir;
plan.exportFile = WalletSecurityController::decryptExportFileName(timestampSeconds);
plan.exportPath = dataDir + plan.exportFile;
plan.walletPath = dataDir + "wallet.dat";
plan.backupPath = dataDir + "wallet.dat.encrypted.bak";
return plan;
}
const char* WalletSecurityWorkflow::stepStatus(DecryptStep step)
{
switch (step) {
case DecryptStep::Unlock: return "Unlocking wallet...";
case DecryptStep::ExportKeys: return "Exporting wallet keys...";
case DecryptStep::StopDaemon: return "Stopping daemon...";
case DecryptStep::BackupWallet: return "Backing up encrypted wallet...";
case DecryptStep::RestartDaemon: return "Restarting daemon...";
case DecryptStep::ImportKeys: return "Importing wallet keys...";
}
return "";
}
const char* WalletSecurityWorkflow::stepLabel(DecryptStep step)
{
switch (step) {
case DecryptStep::Unlock: return "Unlocking wallet";
case DecryptStep::ExportKeys: return "Exporting wallet keys";
case DecryptStep::StopDaemon: return "Stopping daemon";
case DecryptStep::BackupWallet: return "Backing up encrypted wallet";
case DecryptStep::RestartDaemon: return "Restarting daemon";
case DecryptStep::ImportKeys: return "Importing wallet keys";
}
return "";
}
WalletSecurityWorkflow::DecryptStep WalletSecurityWorkflow::stepFromIndex(int step)
{
if (step <= 0) return DecryptStep::Unlock;
if (step == 1) return DecryptStep::ExportKeys;
if (step == 2) return DecryptStep::StopDaemon;
if (step == 3) return DecryptStep::BackupWallet;
if (step == 4) return DecryptStep::RestartDaemon;
return DecryptStep::ImportKeys;
}
bool WalletSecurityWorkflow::stepIsComplete(DecryptStep current, DecryptStep candidate)
{
return stepIndex(candidate) < stepIndex(current);
}
} // namespace services
} // namespace dragonx