Skip to content

fix: block numberpad input exceeding max amount#908

Draft
ovitrif wants to merge 2 commits intomasterfrom
fix/block-input-over-max
Draft

fix: block numberpad input exceeding max amount#908
ovitrif wants to merge 2 commits intomasterfrom
fix/block-input-over-max

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented Apr 23, 2026

Follow-up to #870 (merged) that capped onchain send validation. That PR disabled the Continue button when an amount exceeded the balance, but users could still type whatever they wanted with no explanation of why the button was disabled — poor UX.

Description

Prevents users from entering amounts above the allowed maximum on numberpad screens, using the same pattern as the React Native app:

  • Hard blocks the keypress at numberpad level (nothing enters the input field)
  • Reuses the existing error animation — pressed key flashes red for 500ms
  • Shows a short WARNING toast (1.5s) explaining the limit

Applied to three screens that all suffered from the same "disabled button with no feedback" problem:

  1. Send amount (onchain / lightning / lnurl) — blocks at availableAmount
  2. Transfer to Spending — blocks at maxAllowedToSend (accounts for LSP fees)
  3. Receiving Capacity (Advanced) — blocks at transferValues.maxLspBalance

Implementation

  • Added maxAmount field (defaults to MAX_AMOUNT) and setMaxAmount() setter to AmountInputViewModel
  • Added AmountInputEffect.MaxExceeded one-shot event via SharedFlow so screens can show a toast
  • Each screen wires setMaxAmount(limit) via LaunchedEffect so the limit stays in sync as fees/balances update
  • MaxExceeded is only emitted when a dynamic limit is set (not on the global 999M sats cap)
  • Added Toast.VISIBILITY_TIME_SHORT = 1500L constant

QA Notes

Send (onchain)

  • Fund savings wallet, go to Send → address → amount screen
  • Type an amount exceeding the "Available" balance
  • Verify: keypress blocked, key flashes red, WARNING toast "Insufficient balance" appears (~1.5s)
  • Verify: tapping "Available" still works to set max

Send (lightning)

  • Same flow with a BOLT11 invoice or LNURL
  • Verify same blocking + toast behavior
  • Switch between savings/spending — limit updates dynamically

Transfer to Spending

  • Transfer → Transfer to Spending, type above maxAllowedToSend
  • Verify keypress blocked + red flash + "Spending Balance Maximum" toast with the actual limit
  • 25% and Max buttons still work

Receiving Capacity (Advanced)

  • Transfer → Spending → Advanced, type above maxLspBalance
  • Verify blocking + red flash + "Receiving Capacity Maximum" toast
  • Min/Default/Max buttons still work

Edge cases

  • Entering exactly the max succeeds (not blocked)
  • Switching sats/fiat near the limit still enforces correctly

🤖 Generated with Claude Code

ovitrif and others added 2 commits April 23, 2026 23:30
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ovitrif ovitrif marked this pull request as draft April 23, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant