fix(ui): validate and clamp dialog input

Tighten input handling across several dialogs so bad/edge input can't
produce a doomed request or a confusing display:

- app_security: passphrase strength meter now factors character-class
  diversity — an all-one-class string downgrades one tier so "aaaaaaaa"
  no longer scores as high as a mixed one.
- block_info: clamp the height field to the chain tip and hide/deny
  "Next" at the tip (was only yielding a raw RPC error).
- address_label: trim surrounding whitespace before saving; a
  whitespace-only label clears it (mirrors clearing the icon).
- send_tab: re-clamp the amount when a Max send has its fee bumped in the
  confirm popup (kept the total within budget) and NUL-terminate the
  strncpy'd address/memo when a payment URI overwrites the form.
- settings_page: reject an empty/whitespace-only lite wallet path before
  dispatching an unusable open/restore request.
- peers_tab: guard ExtractIP against an empty address.
- transaction_details: disable "View in explorer" when the configured
  explorer URL is empty/whitespace so we never open a garbage link.
- app: seed-backup "Skip" now requires a second, deliberate click with a
  fund-loss warning before it dismisses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-05 15:08:59 -05:00
parent 41f5548593
commit 658c0f355b
8 changed files with 118 additions and 14 deletions

View File

@@ -725,7 +725,17 @@ void RenderSendConfirmPopup(App* app) {
{
Type().textColored(TypeStyle::Overline, OnSurfaceMedium(), TR("send_network_fee"));
ImGui::Dummy(ImVec2(0, Layout::spacingSm()));
double feeBefore = s_fee;
RenderFeeTierSelector("##confirm");
// If Max was selected, a fee bump here would push total over the available
// balance (s_amount was clamped to available - old fee). Re-clamp so the send
// stays within budget.
if (s_send_max && s_fee != feeBefore) {
double avail = GetAvailableBalance(app);
double maxAmount = avail - s_fee;
if (maxAmount < 0) maxAmount = 0;
s_amount = maxAmount;
}
// Recalculate total after potential fee change
total = s_amount + s_fee;
ImGui::Dummy(ImVec2(0, Layout::spacingMd()));
@@ -1129,9 +1139,16 @@ void RenderSendTab(App* app)
// Handle pending payment from URI
if (app->hasPendingPayment()) {
// A URI arriving mid-compose would silently overwrite the user's in-progress form.
// Capture an undo snapshot first so "Undo" can restore what they were typing.
if (FormHasData()) {
SaveFormSnapshot();
}
strncpy(s_to_address, app->getPendingToAddress().c_str(), sizeof(s_to_address) - 1);
s_to_address[sizeof(s_to_address) - 1] = '\0';
s_amount = app->getPendingAmount();
strncpy(s_memo, app->getPendingMemo().c_str(), sizeof(s_memo) - 1);
s_memo[sizeof(s_memo) - 1] = '\0';
app->clearPendingPayment();
}