fix: cap number pad entry at available balance across amount screens#585
fix: cap number pad entry at available balance across amount screens#585CypherPoet wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f439703d6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The send number pad now rejects keystrokes that would push the amount above the available sendable balance, reusing the existing over-max block (haptic + error flash) via a dynamic maxAmountOverride. Continue-button validation is unchanged as a backstop. Closes synonymdev#346
b96b812 to
6af6d68
Compare
The cap rejected every keystroke whose result still exceeded it, including deletions. When an amount lands above the cap (a prefilled invoice over the available balance, or a cap that dropped after input), the user could not backspace to reduce it, since each intermediate value was still over the cap. Deletions now always apply; the cap only blocks growing the amount.
Applies the maxAmountOverride cap (from the send-amount fix) to the LNURL pay/withdraw, spending, advanced-spending, and manual channel-funding screens, so the number pad refuses entry above each screen's contextual maximum. FundManualAmountView also gains the previously-missing upper-bound button validation, which let users proceed above the fundable balance. Receive and CJIT amount screens are intentionally left uncapped (a receive amount has no balance ceiling).
6af6d68 to
bd7a772
Compare
|
Please, if possible, consolidate both PRs into a single one like synonymdev/bitkit-android#908 to facilitate the E2E updates cc @piotr-iohk |
|
Updated PR description by replacing |
Now that the send-amount cap (synonymdev#584) and the remaining-screens cap live in a single PR, merge the two Fixed fragments into one entry.
Done. I've consolidated the changes for #584 into this PR and merged the two changelog fragments into one. I also closed #584 in favor of this one. @jvsena42 One question: I still have the |
That would still keep PR under |
Replaces the legacy ObservableObject/@StateObject/@ObservedObject pattern with @observable + @State, aligning with the project's stated SwiftUI direction. No behavior change: there are no two-way bindings to the view model, so no @bindable is needed. Touches the view model, NumberPadTextField, and the 8 amount-entry call sites.
@ovitrif Ha!... fair enough. Folded the |
Thanks! I asked for this case just to facilitate the E2E tests updates, because the Android changes were implemented in a single PR |
|
The android counter part PR (synonymdev/bitkit-android#908) implements an error toast (identified by test id: See (ios left / android right): Screen.Recording.2026-06-10.at.12.41.37.mov |
piotr-iohk
left a comment
There was a problem hiding this comment.
See: #585 (comment) 🙏
| .onAppear { | ||
| updateInputCap() | ||
| } | ||
| .onChange(of: wallet.channelFundableBalanceSats) { updateInputCap() } |
There was a problem hiding this comment.
replace with
.onChange(of: wallet.channelFundableBalanceSats, initial: true) { _, _ in
updateInputCap()
}
| .onAppear { | ||
| updateInputCap() | ||
| } | ||
| .onChange(of: maxAmount) { updateInputCap() } |
There was a problem hiding this comment.
Description
Caps number-pad entry at the contextual maximum across the amount-entry screens, so you can no longer type an amount you cannot send. Originally split across three PRs, this work was consolidated here per maintainer request to keep the E2E updates pointed at a single PR (supersedes #584, folds in #586).
maxAmountOverrideonAmountInputViewModeland caps the send screen at the available balance.AmountInputViewModelfromObservableObjectto@Observable.The receive and CJIT amount screens are intentionally left uncapped: a receive amount has no balance ceiling.
Linked Issues/Tasks
Related: #346
Supersedes: #584, #586
Screenshot / Video
pr2-spending-amount-cap.mp4
QA Notes
Manual Tests
regression:Receive / CJIT Amount: no upper cap; any amount can still be entered.Automated Checks
BitkitTests/NumberPadTests.swiftcovers the cap mechanism, including themaxAmountOverridecap and deleting an over-cap amount (testDeleteAllowedWhenAmountAboveCap).NumberPadTestspasses locally on the iOS Simulator (25 tests, 0 failures, run against this branch merged with current master).