feat(wallet): Max fills the fee-aware maxSendable#848
Merged
Conversation
…ndable The Send and Internal-transfer "Max" buttons filled the raw balance, leaving no room for the transaction fee (and, for `total`, even including unconfirmed/immature funds that can't be spent), so the send failed to build or showed insufficient funds: - SendViewModel.fillMaxFromWallet (Core legs) used balance.total - SendAmountModel.selectAllFundsWithoutAuth used balance.spendable - InternalTransferViewModel.fillMaxFromWallet (Core legs) used balance.total All three now use WalletBalance.maxSendable (spendable minus the send fee reserve — the SwiftDashSDK replacement for DSAccount.maxOutputAmount that the rest of the app already caps Max at).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue being fixed or feature implemented
The "Max" buttons in the Send and Internal-transfer flows filled the raw balance, leaving no room for the transaction fee — and for the
total-based ones, even including unconfirmed/immature funds that can't be spent. The resulting amount was not actually sendable, so the send failed to build or showed insufficient funds.What was done?
Routed all three Max fills through
WalletBalance.maxSendable(spendable minus the send fee reserve — the SwiftDashSDK replacement forDSAccount.maxOutputAmountthat the rest of the app already caps Max at, e.g.ContactProfileSheet,BuyCreditsViewController,DashSpendPayViewModel,CrowdNode, and theWalletSendService"callers cap input at maxSendable" contract):SendViewModel.fillMaxFromWallet(Core legs) — wasbalance.totalSendAmountModel.selectAllFundsWithoutAuth(classic amount screen) — wasbalance.spendableInternalTransferViewModel.fillMaxFromWallet(Core legs) — wasbalance.totalOnly the Max fills changed; balance-card display and affordability checks that legitimately use
totalare untouched.How Has This Been Tested?
Clean
dashpaybuild (xcodebuild ... -scheme dashpay -sdk iphonesimulator ARCHS=arm64 build). Not yet smoke-tested on testnet — worth confirming that tapping Max then Send actually broadcasts for a Transparent send and a Core→Shielded internal transfer.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only