feat(wizard/security): reveal toggles, disabled-reasons, whitespace guards, themed colors, secret auto-hide (12 findings)

UX audit, Wizard/Security surface — all 12 findings. (Edits analyzed in parallel per file,
then each old_string verified against the file, logic reviewed, and built/tested together.)

Wizard (app_wizard.cpp):
- F019: show/hide reveal toggle on the encryption-step passphrase fields + shared
  character-class strength downgrade (matches the Settings Encrypt dialog).
- F066: the encryption-step Skip arms to a wide, error-styled "Skip anyway (unencrypted)"
  and disarms on outside interaction.
- F086: enlarge the strength/too-short caption buffers (64/80 -> 256) and wrap them so
  long de/ru/ja translations don't truncate.

Security dialogs (app_security.cpp):
- F018: the Change-passphrase dialog states why the button is disabled (current missing /
  too short / mismatch / must differ) and gains a reveal checkbox over all three fields.
- F036: the Encrypt and Change dialogs reject a passphrase with leading/trailing space/tab
  (matches the wizard) instead of silently accepting it.
- F068: Encrypt / PIN / Decrypt / lock-screen colors use theme tokens instead of raw
  ImVec4/IM_COL32.

Key export (export_all_keys_dialog.cpp, key_export_dialog.cpp):
- F017: export-all-keys shows "Unlock first" + an Unlock button and disables Export while
  the wallet is locked; a plaintext-file caution persists on full or partial export.
- F067: the "Exporting X of N" counter is now an atomic incremented per address (live).
- F035: the key-export card width scales the padding by dpiScale().
- F099: Retry re-dispatches the fetch directly, and a revealed key/QR auto-hides after ~60s
  with a countdown. Choice a.

Validate address (validate_address_dialog.cpp):
- F037: RPC failures show util::friendlyRpcError() instead of raw daemon text.
- F098: Paste strips whitespace into the field and auto-validates via the same handler.
  Choice a.

New strings (English). Build + tests + hygiene green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 16:10:49 -06:00
co-authored by Claude Opus 4.8
parent fc6b854a00
commit 2b16556990
6 changed files with 252 additions and 63 deletions
+85 -23
View File
@@ -1264,13 +1264,37 @@ void App::renderFirstRunWizard() {
dl->AddText(captionFont, captionFont->LegacySize, ImVec2(cx, cy), dimCol, TR("wiz_passphrase"));
cy += captionFont->LegacySize + 4.0f * dp;
// Reveal toggle state + armed-skip state live for this step only: if the step was not
// rendered on the previous frame (user left and came back), start masked / disarmed.
static bool s_wizShowPass = false;
static bool s_wizSkipArmed = false;
static int s_wizLastFrame = -10;
if (ImGui::GetFrameCount() != s_wizLastFrame + 1) {
s_wizShowPass = false;
s_wizSkipArmed = false;
}
s_wizLastFrame = ImGui::GetFrameCount();
const ImGuiInputTextFlags wizPwFlags = s_wizShowPass ? 0 : ImGuiInputTextFlags_Password;
ImGui::SetCursorScreenPos(ImVec2(cx, cy));
ImGui::PushItemWidth(contentW);
const float wizEyeSz = ImGui::GetFrameHeight();
const float wizEyeGap = 6.0f * dp;
ImGui::PushItemWidth(contentW - wizEyeSz - wizEyeGap);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 6.0f * dp);
ImGui::InputText("##wiz_pass", encrypt_pass_buf_, sizeof(encrypt_pass_buf_),
ImGuiInputTextFlags_Password);
ImGui::InputText("##wiz_pass", encrypt_pass_buf_, sizeof(encrypt_pass_buf_), wizPwFlags);
ImGui::PopStyleVar();
ImGui::PopItemWidth();
ImGui::SameLine(0, wizEyeGap);
{
ui::material::IconButtonStyle eyeSt;
eyeSt.hoverBg = ui::material::WithAlpha(ui::material::OnSurface(), 30);
eyeSt.bgRounding = 4.0f * dp;
eyeSt.tooltip = TR("enc_show_pass");
if (ui::material::IconButton("##wiz_reveal",
s_wizShowPass ? ICON_MD_VISIBILITY_OFF : ICON_MD_VISIBILITY,
ui::material::Type().iconSmall(), ImVec2(wizEyeSz, wizEyeSz), eyeSt))
s_wizShowPass = !s_wizShowPass;
}
cy += 36.0f * dp + 6.0f * dp;
dl->AddText(captionFont, captionFont->LegacySize, ImVec2(cx, cy), dimCol, TR("wiz_confirm"));
@@ -1280,7 +1304,7 @@ void App::renderFirstRunWizard() {
ImGui::PushItemWidth(contentW);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 6.0f * dp);
ImGui::InputText("##wiz_confirm", encrypt_confirm_buf_, sizeof(encrypt_confirm_buf_),
ImGuiInputTextFlags_Password);
wizPwFlags);
ImGui::PopStyleVar();
ImGui::PopItemWidth();
cy += 36.0f * dp + 6.0f * dp;
@@ -1292,11 +1316,27 @@ void App::renderFirstRunWizard() {
ImU32 strengthCol = ui::material::Error();
float strengthPct = 0.25f;
if (len >= 16) {
// Character-class diversity (matches the Settings Encrypt dialog): an all-digit or
// single-class passphrase scores one tier lower than a mixed one of the same length.
bool hasDigit = false, hasLower = false, hasUpper = false, hasSymbol = false;
for (const char* c = encrypt_pass_buf_; *c; ++c) {
unsigned char uc = static_cast<unsigned char>(*c);
if (uc >= '0' && uc <= '9') hasDigit = true;
else if (uc >= 'a' && uc <= 'z') hasLower = true;
else if (uc >= 'A' && uc <= 'Z') hasUpper = true;
else hasSymbol = true;
}
const int classes = (int)hasDigit + (int)hasLower + (int)hasUpper + (int)hasSymbol;
int tier = 0; // 0=Weak, 1=Fair, 2=Good, 3=Strong
if (len >= 16) tier = 3;
else if (len >= 12) tier = 2;
else if (len >= 8) tier = 1;
if (classes <= 1 && tier > 0) tier -= 1;
if (tier == 3) {
strengthLabel = TR("wiz_strength_strong"); strengthCol = ui::material::Secondary(); strengthPct = 1.0f;
} else if (len >= 12) {
} else if (tier == 2) {
strengthLabel = TR("wiz_strength_good"); strengthCol = ui::material::Secondary(); strengthPct = 0.75f;
} else if (len >= 8) {
} else if (tier == 1) {
strengthLabel = TR("wiz_strength_fair"); strengthCol = ui::material::Warning(); strengthPct = 0.5f;
}
@@ -1309,26 +1349,30 @@ void App::renderFirstRunWizard() {
}
cy += sBarH + 4.0f * dp;
char slabel[64];
char slabel[256];
snprintf(slabel, sizeof(slabel), TR("wiz_strength"), strengthLabel);
dl->AddText(captionFont, captionFont->LegacySize, ImVec2(cx, cy), dimCol, slabel);
cy += captionFont->LegacySize + 10.0f * dp;
ImVec2 slSize = captionFont->CalcTextSizeA(captionFont->LegacySize, FLT_MAX, contentW, slabel);
dl->AddText(captionFont, captionFont->LegacySize, ImVec2(cx, cy), dimCol, slabel, nullptr, contentW);
cy += slSize.y + 10.0f * dp;
}
// Feedback on why Encrypt is disabled
{
size_t pLen = strlen(encrypt_pass_buf_);
if (pLen > 0 && pLen < 8) {
char fb[80];
char fb[256];
snprintf(fb, sizeof(fb), TR("wiz_pass_too_short"), pLen);
ImVec2 fbSize = captionFont->CalcTextSizeA(captionFont->LegacySize, FLT_MAX, contentW, fb);
dl->AddText(captionFont, captionFont->LegacySize, ImVec2(cx, cy),
ui::material::Error(), fb);
cy += captionFont->LegacySize + 6.0f * dp;
ui::material::Error(), fb, nullptr, contentW);
cy += fbSize.y + 6.0f * dp;
} else if (pLen >= 8 && strlen(encrypt_confirm_buf_) > 0 &&
strcmp(encrypt_pass_buf_, encrypt_confirm_buf_) != 0) {
const char* mm = TR("wiz_pass_mismatch");
ImVec2 mmSize = captionFont->CalcTextSizeA(captionFont->LegacySize, FLT_MAX, contentW, mm);
dl->AddText(captionFont, captionFont->LegacySize, ImVec2(cx, cy),
ui::material::Error(), TR("wiz_pass_mismatch"));
cy += captionFont->LegacySize + 6.0f * dp;
ui::material::Error(), mm, nullptr, contentW);
cy += mmSize.y + 6.0f * dp;
}
}
@@ -1385,9 +1429,10 @@ void App::renderFirstRunWizard() {
// Status
if (!encrypt_status_.empty()) {
ImVec2 stSize = captionFont->CalcTextSizeA(captionFont->LegacySize, FLT_MAX, contentW, encrypt_status_.c_str());
dl->AddText(captionFont, captionFont->LegacySize, ImVec2(cx, cy),
ui::material::Warning(), encrypt_status_.c_str());
cy += captionFont->LegacySize + 6.0f * dp;
ui::material::Warning(), encrypt_status_.c_str(), nullptr, contentW);
cy += stSize.y + 6.0f * dp;
}
// Warn + block if the passphrase has leading/trailing whitespace. Silently trimming it would
@@ -1417,7 +1462,8 @@ void App::renderFirstRunWizard() {
bool canEncrypt = passValid && pinOk && !encrypt_in_progress_;
float encBtnW = 180.0f * dp;
float skipW2 = 80.0f * dp;
const char* skipLabel = s_wizSkipArmed ? TR("wiz_skip_anyway") : TR("wiz_skip");
float skipW2 = std::max(80.0f * dp, ImGui::CalcTextSize(skipLabel).x + 32.0f * dp);
float btnH2 = 40.0f * dp;
float totalBW = encBtnW + 12.0f * dp + skipW2;
float bx = rightX + (colW - totalBW) * 0.5f;
@@ -1440,6 +1486,8 @@ void App::renderFirstRunWizard() {
settings_->setEncryptionPending(true);
// Clear sensitive buffers
s_wizShowPass = false;
s_wizSkipArmed = false;
memset(encrypt_pass_buf_, 0, sizeof(encrypt_pass_buf_));
memset(encrypt_confirm_buf_, 0, sizeof(encrypt_confirm_buf_));
memset(wizard_pin_buf_, 0, sizeof(wizard_pin_buf_));
@@ -1465,14 +1513,28 @@ void App::renderFirstRunWizard() {
ImGui::SetCursorScreenPos(ImVec2(bx + encBtnW + 12.0f * dp, cy));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 8.0f * dp);
if (ui::material::TactileButton(TR("wiz_skip"), ImVec2(skipW2, btnH2))) {
static bool s_skipEncConfirm = false;
if (!s_skipEncConfirm) {
if (s_wizSkipArmed) {
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::ColorConvertU32ToFloat4(ui::material::Error()));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::ColorConvertU32ToFloat4(ui::material::Error()));
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(ui::material::OnPrimary()));
}
const bool skipClicked = ui::material::TactileButton(skipLabel, ImVec2(skipW2, btnH2));
const bool skipHovered = ImGui::IsItemHovered();
if (s_wizSkipArmed) ImGui::PopStyleColor(3);
// Disarm when the user clicks anywhere else (a click on Skip is handled below).
if (s_wizSkipArmed && !skipClicked && !skipHovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
s_wizSkipArmed = false;
if (encrypt_status_ == TR("wiz_skip_confirm")) encrypt_status_.clear();
}
if (skipClicked) {
if (!s_wizSkipArmed) {
// Skipping stores private keys UNENCRYPTED — require a confirming second click.
s_skipEncConfirm = true;
s_wizSkipArmed = true;
encrypt_status_ = TR("wiz_skip_confirm");
} else {
s_skipEncConfirm = false;
s_wizSkipArmed = false;
s_wizShowPass = false;
encrypt_status_.clear();
// Skipping leaves the wallet UNENCRYPTED — wipe the passphrase/PIN the user may have
// typed so it doesn't linger in these process-lifetime buffers (only the Encrypt
// path cleared them before). (L-07)