feat(settings): rename to "Import Private Key" + add scan height to it

Follow-up to the key/viewing-key button split:

- Rename the "Import Key…" button to "Import Private Key…" (settings_import_key
  value in en + all 8 langs, reusing the existing import_key_title wording) so it
  reads as the natural counterpart to "Import Viewing Key…". The dialog title was
  already "Import Private Key". The viewing-key wrong-type redirect hint now names
  the renamed button.

- Show the "scan from block height" field in the private-key (spending) dialog too,
  not just the viewing-key one. z_importkey accepts a start height, so a shielded
  spend import of a recent key needn't rescan the whole chain. Transparent WIF
  (importprivkey) has no such param, so once a transparent key is recognized the
  field is disabled, its buffer cleared, and a "Transparent keys always rescan
  fully" note replaces the hint. importPrivateKey already gates the start-height
  append on (viewing || shielded), so transparent imports never receive it.

- i18n: shared scan keys renamed import_viewkey_scan_{label,hint} ->
  import_scan_{label,hint}; added import_scan_transparent (en + 8 langs).

Reviewed via an adversarial multi-agent pass (rpc-routing / i18n / ui-logic /
consistency); only two nits surfaced (stale disabled-field value + a stale
comment), both fixed here.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-13 14:38:40 -05:00
parent f428292ea4
commit 1fc3e03e6f
11 changed files with 60 additions and 44 deletions

View File

@@ -2862,15 +2862,22 @@ void App::renderImportKeyDialog()
}
ImGui::Spacing();
// Optional scan-from height (viewing keys only — z_importviewingkey takes a start height, so a
// watch-only import of a recent address needn't rescan the whole chain).
if (viewMode) {
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(m::OnSurfaceMedium()), "%s", TR("import_viewkey_scan_label"));
// Optional scan-from height. z_importkey / z_importviewingkey accept a start block, so a shielded
// import of a recent key needn't rescan the whole chain. Transparent WIF (importprivkey) has no
// start-height parameter, so the field is disabled + noted once a transparent key is recognized.
{
const bool transparentKey = !viewMode && isSpend && !shielded; // recognized transparent WIF
if (transparentKey && import_key_scan_height_[0])
sodium_memzero(import_key_scan_height_, sizeof(import_key_scan_height_)); // no stale height in the disabled box
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(m::OnSurfaceMedium()), "%s", TR("import_scan_label"));
ImGui::BeginDisabled(transparentKey);
ImGui::SetNextItemWidth(140.0f * dp);
ImGui::InputText("##importscanheight", import_key_scan_height_, sizeof(import_key_scan_height_),
ImGuiInputTextFlags_CharsDecimal);
ImGui::EndDisabled();
ImGui::SameLine(0, ui::Layout::spacingSm());
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(m::OnSurfaceDisabled()), "%s", TR("import_viewkey_scan_hint"));
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(m::OnSurfaceDisabled()), "%s",
transparentKey ? TR("import_scan_transparent") : TR("import_scan_hint"));
ImGui::Spacing();
}
@@ -2907,8 +2914,8 @@ void App::renderImportKeyDialog()
import_success_ = false;
import_status_.clear();
import_result_address_.clear();
int startHeight = 0; // viewing-key only; 0 = full rescan (also the transparent/spending default)
if (viewMode && import_key_scan_height_[0]) {
int startHeight = 0; // 0 = full rescan. Shielded imports (z_importkey/z_importviewingkey) honor
if (import_key_scan_height_[0]) { // it; importPrivateKey ignores it for transparent WIF.
startHeight = std::atoi(import_key_scan_height_);
if (startHeight < 0) startHeight = 0;
}

View File

@@ -811,7 +811,7 @@ private:
bool import_in_progress_ = false; // an import + rescan is running (disable/spinner)
std::string import_result_address_; // address imported on success (shown as a copy field)
bool import_view_mode_ = false; // dialog mode: false = spending key, true = viewing key
char import_key_scan_height_[16] = {0}; // optional rescan start height (viewing-key mode)
char import_key_scan_height_[16] = {0}; // optional rescan start height (shielded spend / viewing-key imports)
std::string backup_status_;
bool backup_success_ = false;

View File

@@ -428,7 +428,7 @@ void I18n::loadBuiltinEnglish()
strings_["settings_shield_mining"] = "Shield Mining...";
strings_["settings_merge_to_address"] = "Merge to Address...";
strings_["settings_clear_ztx"] = "Clear Z-Tx History";
strings_["settings_import_key"] = "Import Key...";
strings_["settings_import_key"] = "Import Private Key...";
strings_["settings_import_viewkey"] = "Import Viewing Key...";
strings_["settings_export_key"] = "Export Key...";
strings_["settings_export_all"] = "Export All...";
@@ -1365,9 +1365,10 @@ void I18n::loadBuiltinEnglish()
strings_["import_viewkey_note"] = "Watch-only: a viewing key reveals an address's balance and transactions but cannot spend its funds.";
strings_["import_viewkey_field"] = "Viewing key";
strings_["import_key_wrong_type"] = "This looks like a viewing key. Use \"Import Viewing Key\" instead.";
strings_["import_viewkey_wrong_type"] = "This looks like a spending key. Use \"Import Key\" instead.";
strings_["import_viewkey_scan_label"] = "Scan from block height (optional)";
strings_["import_viewkey_scan_hint"] = "0 = rescan from the start";
strings_["import_viewkey_wrong_type"] = "This looks like a spending key. Use \"Import Private Key\" instead.";
strings_["import_scan_label"] = "Scan from block height (optional)";
strings_["import_scan_hint"] = "0 = rescan from the start";
strings_["import_scan_transparent"] = "Transparent keys always rescan fully";
// --- Key Export Dialog ---
strings_["key_export_fetching"] = "Fetching key from wallet...";