Skip to content

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
fix/dust-change-send-all
Open

Use sendAll when change would be dust instead of creating dust change outputs#451
ben-kaufman wants to merge 2 commits intofeat/multiple-addresses-typesfrom
fix/dust-change-send-all

Conversation

@ben-kaufman
Copy link
Contributor

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

  1. Correct fee in dust check
    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.
  2. DustChangeHelper
    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).

ben-kaufman and others added 2 commits February 19, 2026 18:35
…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>
@ben-kaufman ben-kaufman marked this pull request as ready for review February 20, 2026 05:03
@ben-kaufman ben-kaufman requested a review from jvsena42 February 20, 2026 05:03
Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

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.

2 participants

Comments