Skip to content

feat(wallet): Max fills the fee-aware maxSendable#848

Merged
QuantumExplorer merged 1 commit into
swift-sdk-integrationfrom
fix/max-amount
Jul 17, 2026
Merged

feat(wallet): Max fills the fee-aware maxSendable#848
QuantumExplorer merged 1 commit into
swift-sdk-integrationfrom
fix/max-amount

Conversation

@romchornyi

Copy link
Copy Markdown
Contributor

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 for DSAccount.maxOutputAmount that the rest of the app already caps Max at, e.g. ContactProfileSheet, BuyCreditsViewController, DashSpendPayViewModel, CrowdNode, and the WalletSendService "callers cap input at maxSendable" contract):

  • SendViewModel.fillMaxFromWallet (Core legs) — was balance.total
  • SendAmountModel.selectAllFundsWithoutAuth (classic amount screen) — was balance.spendable
  • InternalTransferViewModel.fillMaxFromWallet (Core legs) — was balance.total

Only the Max fills changed; balance-card display and affordability checks that legitimately use total are untouched.

How Has This Been Tested?

Clean dashpay build (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:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

…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).
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cbad6f53-cac2-410c-91ec-de053bfb400e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/max-amount

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@QuantumExplorer
QuantumExplorer merged commit 54e66c8 into swift-sdk-integration Jul 17, 2026
2 checks passed
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.

3 participants