Files
ObsidianDragon/tests
DanSandClaude Opus 4.8 0a957e9555 fix(import): strip Unicode whitespace from pasted keys before import/sweep
Users (notably in the Chinese community) hit "Invalid spending key" when
importing/sweeping an otherwise-valid shielded spending key. Root cause: the
Import Key dialog classified the TRIMMED key (so the UI showed it as valid) but
handed the RAW import_key_input_ buffer to z_importkey/sweep — and the trim was
ASCII-only (' ' \t \n \r). CJK clipboards commonly inject whitespace that an
ASCII trim leaves behind — above all a trailing U+3000 ideographic space, plus
NBSP / zero-width / BOM — so a trailing such character passed the prefix
classifier (UI "valid") but reached the daemon's DecodeSpendingKey() verbatim,
which failed the Bech32 decode → "Invalid spending key". Native Ctrl+V also
bypassed the paste-button trim entirely, so even plain ASCII whitespace reached
the RPC. This is why it hit CJK users systematically and others rarely.

Add util::stripAllWhitespaceForKey (UTF-8 aware; removes every whitespace code
point, ASCII + Unicode, including internal ones — a key is a single token). The
dialog now classifies AND sends this cleaned key (keyTrim), the key Paste button
cleans the field with it, and trimmedClipboardText (addresses etc.) now
edge-trims Unicode whitespace too. Covers spending, viewing, and WIF imports and
the sweep path. Present in v2.0.2 and current dev (same gate).

Adds testKeyInputSanitization (trailing U+3000 / NBSP / BOM / zero-width /
internal newline → clean key; and the end-to-end classify-after-clean case).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-15 11:04:20 -06:00
..