Skip to content

Add min_change_value - #94

Open
aagbotemi wants to merge 1 commit into
bitcoindevkit:masterfrom
aagbotemi:feat/lowest-fee-min-change-value
Open

aagbotemi wants to merge 1 commit into
bitcoindevkit:masterfrom
aagbotemi:feat/lowest-fee-min-change-value

Conversation

@aagbotemi

@aagbotemi aagbotemi commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds min_change_value to LowestFee. Change below it is not created, and the excess goes to fee instead. Use 0 to keep the current behavior.

Note to Reviewers

LowestFee has no way to take a minimum change value. Since #49, LowestFee no longer accepts a ChangePolicy, so callers with a minimum have to apply it after branch and bound returns. That decides change twice, which #49 set out to remove: BnB picks a selection for its change, the caller drops that change, and the excess is paid as fee. bdk-tx hits this in bitcoindevkit/bdk-tx#47, where it drops change below change_min_value after run_bnb.
The minimum is checked after the spend-cost and dust checks in drain_value. It can only remove change, never force it, so the proof in bound for selections with change still holds.

For selections without change, LowestFee::bound assumes a change output costs output_weight * feerate. That is not true when the absolute or replacement fee is the binding constraint, so the bound can prune a cheaper selection that has change (#83). This PR makes that easier to hit, since change below min_change_value widens the window where it applies, so it should land after the fix for #83.

Changelog notice

  • Breaking: LowestFee takes a min_change_value: u64. Change below it is not created, and the excess goes to fee. Use 0 to keep the previous behavior.

Checklists

@aagbotemi
aagbotemi force-pushed the feat/lowest-fee-min-change-value branch from 28090aa to efc1871 Compare December 3, 2026 19:28
@aagbotemi
aagbotemi marked this pull request as ready for review December 3, 2026 21:02
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.

1 participant