ADD: show MAX sendable amount#8264
Conversation
When MAX is selected, display the calculated sendable amount below. - Works only for 1 recipient (Main goal of feature is this for atomic swap) - Shows ≈ prefix when recipient address is unknown (using P2TR estimate) - Shows exact amount when valid address is entered - Forces displayed amount into transaction (no recalculation on Next)
|
Add some screenshots please |
|
I did in issue #8265 may I copy it too or link is enough? |
Thanks, that is great! |
There was a problem hiding this comment.
Pull request overview
This PR implements a feature to display the calculated sendable amount when MAX is selected for atomic swap compatibility. When a user selects "Use Full Balance" (MAX), the actual BTC amount that will be sent is now displayed below the MAX label, making it easier to communicate the exact amount to a counterparty before receiving their address.
Changes:
- Calculates and displays the maximum sendable amount (balance minus fee) when MAX is selected for single-recipient transactions
- Uses P2TR dummy address for conservative fee estimation when no valid address is entered, showing ≈ prefix to indicate estimate
- Shows exact amount when a valid address is entered
- Commits to the displayed amount in transaction creation, with any remainder going to the fee
- Adds long-press to copy functionality for the displayed amount
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| screen/send/SendDetails.tsx | Adds maxSendableAmount calculation, updates fee estimation to use P2TR dummy for conservative estimates, modifies transaction creation to use explicit value when MAX is displayed |
| components/AmountInput.tsx | Adds UI to display the MAX sendable amount with optional ≈ prefix, implements copy-to-clipboard on long press |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| editable={isEditable} | ||
| disabled={!isEditable} | ||
| inputAccessoryViewID={InputAccessoryAllFundsAccessoryViewID} | ||
| maxSendableAmount={index === scrollIndex.current ? maxSendableAmount : null} |
There was a problem hiding this comment.
The condition index === scrollIndex.current appears unnecessary here since maxSendableAmount is already null when addresses.length !== 1 (line 116 in maxSendableAmount calculation). This means if there are multiple recipients, maxSendableAmount will already be null regardless of the scroll index.
Consider simplifying this to just maxSendableAmount={maxSendableAmount} or adding a comment explaining why the scroll index check is needed.
| maxSendableAmount={index === scrollIndex.current ? maxSendableAmount : null} | |
| maxSendableAmount={maxSendableAmount} |
|
Pushed the refactor - moved maxSendableAmount calculation into the recalc fees in effect useEffect as @limpbrains suggested. |
|
@cursor review pls |
|
running full test suite here: #8285 |
|
e2e test failed: test.mp4test.mp4 |
|
additionally, cursor complained: Max sendable amount overestimated with dust UTXOs High Severity The maxSendableAmount is computed as balance - newFeePrecalc.current, where balance is the total of ALL UTXOs but newFeePrecalc.current is the fee calculated by coinSelectSplit, which skips detrimental UTXOs (those costing more in fees than they're worth). This overstates the sendable amount by the sum of those skipped UTXOs. When createPsbtTransaction then forces this inflated value via targets.push({ address, value: maxSendableAmount }), coinSelect also skips the detrimental UTXOs and can't find enough funds, causing a "Not enough balance" error on a MAX send. |
|
Fixed two issues with maxSendableAmount:
@Overtorment could you check it again if I do not miss anything? |
|
Wake the fuck up samurai, we have PRs to merge [all PRs for @Overtorment] https://github.com/BlueWallet/BlueWallet/pulls/review-requested/Overtorment |
|
I opened a new PR to run the full test suite with all CI env vars/secrets available: #8327 Running all tests there. |
Overtorment
left a comment
There was a problem hiding this comment.
LGTM! running test-suite to make sure all is good and we can merge




Fixes #8265
When MAX is selected, display the calculated sendable amount below.