forked from bitcoin-teleport/teleport-transactions
-
Notifications
You must be signed in to change notification settings - Fork 98
Closed
Description
Summary
The coin_select function incorrectly determines whether regular or swap UTXOs can cover a transaction by only checking if the target amount is available, without accounting for estimated transaction fees. This causes coin selection to fail even when sufficient total balance exists.
Problem Description
Root Cause
The can_use_regular and can_use_swap boolean flags were computed using only the target amount:
// (Thi is Buggy) behavior)
let can_use_regular = target_sats <= regular_total;
let can_use_swap = target_sats <= swap_total;This creates an edge case where:
can_use_regularis flagged astrue(e.g.,29,000 <= 29,296)- The function attempts coin selection with regular UTXOs
- Coin selection fails because
target + estimated_fee > regular_total(e.g.,29,000 + 324 = 29,324 > 29,296becomes false after coinselect's overshoot) - The function returns an error instead of falling back to swap UTXOs
FUrthermore
The rust-coinselect library can overshoot the fee estimate by a few satoshis above the estimated_fee + target range, making this issue more pronounced when:
- The target amount is small
- Regular UTXO balance is just barely above the target
- Swap UTXO balance has sufficient funds to cover target + fees + overshoot
Metadata
Metadata
Assignees
Labels
No labels