bitcoindevkit / bitcoindevkit/bdk_wallet
Fee bump with `fee_absolute` accepts equal fee and does not check fee rate
- Dominant language
- Rust
- Stars
- 59
- Forks
- 105
- Avg merge
- 10d 9h
- Merged PRs (30d)
- 1
Description
**Describe the bug**
When bumping a fee with `TxBuilder::fee_absolute`, `Wallet::create_tx` only checks `fee < previous_fee.absolute` (`src/wallet/mod.rs`, `FeePolicy::FeeAmount` arm). Two things are missing compared to the `FeePolicy::FeeRate` arm:
- A replacement paying exactly the same absolute fee as the original passes the check.
- The resulting fee rate is never compared to the original's. A replacement that is larger than the original (e.g. more inputs after coin selection) can end up with a lower fee rate than the original, and even a larger fee may not cover the incremental relay fee.
Such transactions are built without error but are rejected by BIP125 replacement policy (rule 4: must pay for its own bandwidth at the incremental relay fee; Bitcoin Core additionally requires a higher fee rate than the original).
This issue was found by AI.
**To Reproduce**
```rust
let (mut wallet, _) = get_funded_wallet_wpkh();
let addr = wallet.next_unused_address(KeychainKind::External);
let mut builder = wallet.build_tx();
builder.add_recipient(addr.script_pubkey(), Amount::from_sat(25_000));
let psbt = builder.finish().unwrap();
let tx = psbt.extract_tx().unwrap();
let original_fee = wallet.calculate_fee(&tx).unwrap();
let txid = tx.compute_txid();
insert_tx(&mut wallet, tx);
let mut builder = wallet.build_fee_bump(txid).unwrap();
builder.fee_absolute(original_fee);
// Succeeds although the replacement pays no more than the original.
builder.finish().unwrap();
```
**Expected behavior**
`fee_absolute` fee bumps should be validated consistently with the `fee_rate` path so that the builder rejects replacements that would not be relayed.
**Build environment**
- BDK tag/commit: `6fc68462` (master)
**Which backend(s) are relevant (if any)?**
- [x] None / not backend-related (e.g. `bdk_chain`, `bdk_core`)
**Is this blocking production use?**
- [x] No
Contributor guide
Research direction
Start in src/wallet/mod.rs at the FeePolicy::FeeAmount arm in Wallet::create_tx, then compare its checks with the FeePolicy::FeeRate arm. Reproduce the equal-fee case from the issue and add coverage for equal fees and replacements with an insufficient fee rate. Done means fee_absolute rejects replacements that would not satisfy the stated replacement-policy checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100