Use sendAll when change would be dust instead of creating dust change outputs#451
Open
ben-kaufman wants to merge 2 commits intofeat/multiple-addresses-typesfrom
Open
Use sendAll when change would be dust instead of creating dust change outputs#451ben-kaufman wants to merge 2 commits intofeat/multiple-addresses-typesfrom
ben-kaufman wants to merge 2 commits intofeat/multiple-addresses-typesfrom
Conversation
…hange output Use normal fee (recipient + change) instead of sendAll fee when checking if change would be dust. The sendAll fee was for a 1-output tx, causing expectedChange to be overestimated and dust change outputs to be created when sending almost the max amount.
Co-authored-by: Cursor <cursoragent@cursor.com>
jvsena42
reviewed
Feb 20, 2026
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.
Problem
When sending close to the maximum amount, the app sometimes created dust change outputs instead of using sendAll. This happened because the dust check used the sendAll fee (1-output tx) instead of the normal fee (recipient + change). That overestimated expected change and made the dust check pass when it should not.
Solution
Use the normal fee (recipient + change outputs) when deciding if change would be dust. If change is below the dust limit, use sendAll so the extra amount goes to fees instead of a dust output.
Added DustChangeHelper.shouldUseSendAllToAvoidDust() to centralize the logic.
Added unit tests for the dust-change decision.
Applied in both SendConfirmationView (onchain send) and SpendingConfirm (Blocktank channel purchase).