Skip to content

fix(wallet): avoid overcounting foreign input weight in build_fee_bump - #667

Open
reez wants to merge 1 commit into
bitcoindevkit:masterfrom
reez:overshoot
Open

reez wants to merge 1 commit into
bitcoindevkit:masterfrom
reez:overshoot

Conversation

@reez

@reez reez commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Description

build_fee_bump reads a foreign input's satisfaction weight from the transaction being replaced. It was counting the scriptSig length byte and the witness item count, which coin selection already counts in TxIn::default().segwit_weight(), so each foreign input came out 5 WU too heavy.

This uses txin.segwit_weight() - TxIn::default().segwit_weight() instead, the same definition as max_weight_to_satisfy (the two stopped agreeing when bitcoindevkit/bdk#1345 changed the base input weight)

Notes to the reviewers

2 things I'd like feedback on:

  • Foreign inputs now get no slack. An ECDSA re-signature can be a byte longer than the original, which the old 5 WU happened to cover. Should there be an explicit margin instead?
  • The test covers native segwit, nested segwit and legacy foreign inputs in one loop, with placeholder bytes in place of real signatures. Is that good enough?

Before submitting

@reez
reez requested a review from a team as a code owner December 4, 2026 18:58
@github-project-automation github-project-automation Bot moved this to Triage in BDK Wallet Dec 4, 2026
@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.69%. Comparing base (a34ca30) to head (78f5187).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #667      +/-   ##
==========================================
- Coverage   81.70%   81.69%   -0.01%     
==========================================
  Files          23       23              
  Lines        5056     5054       -2     
  Branches      217      217              
==========================================
- Hits         4131     4129       -2     
  Misses        852      852              
  Partials       73       73              
Flag Coverage Δ
rust 81.69% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reez reez moved this from Triage to In Progress in BDK Wallet Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant