fix(security): color seed-save by outcome; explain the Encrypt button; friendly key-export errors

- Seed-backup dialog: a failed "Save to file" was drawn in the success (green)
  colour; it's now red on failure, green on success (flag reset on close).
- Encrypt-wallet dialog: the disabled Encrypt button now says why once the user
  starts typing ("Use at least 8 characters." / "The passphrases don't match."),
  and a "Show passphrase" checkbox reveals both fields.
- Key-export dialog: the raw RPC exception (e.g. "...walletpassphrase first")
  is routed through util::friendlyRpcError(), so a locked wallet reads
  "Unlock your wallet first, then try again." instead of daemon jargon.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-10-18 09:09:29 -05:00
co-authored by Claude Opus 4.8
parent 7d2972f315
commit 4c6a78b3b0
5 changed files with 25 additions and 9 deletions
+14 -6
View File
@@ -1452,15 +1452,16 @@ void App::renderEncryptWalletDialog() {
ImGui::TextUnformatted(TR("wiz_passphrase"));
ImGui::PushItemWidth(-1);
ImGui::InputText("##enc_pass", encrypt_pass_buf_, sizeof(encrypt_pass_buf_),
ImGuiInputTextFlags_Password);
static bool s_showEncPass = false;
const ImGuiInputTextFlags encPwFlags = s_showEncPass ? 0 : ImGuiInputTextFlags_Password;
ImGui::InputText("##enc_pass", encrypt_pass_buf_, sizeof(encrypt_pass_buf_), encPwFlags);
ImGui::PopItemWidth();
ImGui::TextUnformatted(TR("enc_confirm"));
ImGui::PushItemWidth(-1);
ImGui::InputText("##enc_confirm", encrypt_confirm_buf_, sizeof(encrypt_confirm_buf_),
ImGuiInputTextFlags_Password);
ImGui::InputText("##enc_confirm", encrypt_confirm_buf_, sizeof(encrypt_confirm_buf_), encPwFlags);
ImGui::PopItemWidth();
ImGui::Checkbox(TR("enc_show_pass"), &s_showEncPass);
// Strength meter bar
{
@@ -1508,8 +1509,15 @@ void App::renderEncryptWalletDialog() {
}
ImGui::Spacing();
bool valid = strlen(encrypt_pass_buf_) >= 8 &&
strcmp(encrypt_pass_buf_, encrypt_confirm_buf_) == 0;
const size_t encPassLen = strlen(encrypt_pass_buf_);
const bool encMatch = strcmp(encrypt_pass_buf_, encrypt_confirm_buf_) == 0;
bool valid = encPassLen >= 8 && encMatch;
// Say WHY the button is disabled, once the user has started typing (was silent before).
if (!valid && (encPassLen > 0 || strlen(encrypt_confirm_buf_) > 0)) {
const char* why = (encPassLen < 8) ? TR("enc_min_len")
: (!encMatch ? TR("enc_mismatch") : "");
if (*why) ImGui::TextColored(ImVec4(1.0f, 0.7f, 0.3f, 1.0f), "%s", why);
}
float btnW = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) * 0.5f;
ImGui::BeginDisabled(!valid || encrypt_in_progress_);