-
Notifications
You must be signed in to change notification settings - Fork 63
Description
Add a configurable dust threshold to Wallet that filters outputs below a specified satoshi value from balance calculations, sent_and_received(), and UTXO iteration methods.
Currently, to exclude dust outputs (e.g., < 1000 sats) from wallet operations, users must:
- Manually iterate list_unspent() and filter by value
- Reimplement BDK's internal logic for categorizing UTXOs into confirmed, trusted_pending, untrusted_pending, and immature
- Manually calculate sent_and_received() by iterating transaction inputs/outputs and looking up previous outputs
This is error-prone and requires duplicating internal BDK logic that may change between versions.
Proposed API
// Option 1: Builder pattern
let wallet = Wallet::builder()
.descriptor(descriptor)
.change_descriptor(change_descriptor)
.dust_threshold(Amount::from_sat(1000))
.network(Network::Bitcoin)
.build()?;
// Option 2: Runtime configuration
wallet.set_dust_threshold(Some(Amount::from_sat(1000)));
// These would now respect the threshold:
let balance = wallet.balance(); // Excludes UTXOs < 1000 sats
let (sent, received) = wallet.sent_and_received(&tx); // Excludes dust outputs
let utxos = wallet.list_unspent(); // Excludes dust UTXOs
Use case
We operate a multi-sig custody platform where dust outputs create operational overhead:
- Users see confusing small amounts in their balance
- Transaction history shows spam/dust attack outputs
- Consolidating dust costs more in fees than the outputs are worth
- Affects user privacy by triggering the common ownership heuristic
We need consistent dust filtering across all wallet operations. Currently we're forced to bypass wallet.balance() and sent_and_received() entirely, manually reimplementing the UTXO categorization logic.
Impact
- Nice-to-have / UX improvement
- Developer experience / maintainability
Are you using BDK in a production project?
- Yes
Which backend(s) are relevant (if any)?
- Electrum
- Esplora
- Bitcoin Core RPC
Project or organization (optional)
AnchorWatch - Bitcoin custody platform
Additional context
The 546 sat dust limit is a relay policy, but many applications want higher thresholds (1000+ sats) for UX reasons. A configurable threshold at the wallet level would be more ergonomic than forcing every consumer
to reimplement filtering logic.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status