rust-coinselect v0.1.6 – A Blockchain-Agnostic Coin Selection Library in Rust
Latest Patch Release | github| docs.rs | crates.io
We’re pleased to announce rust-coinselect v0.1.6, a minor release with introduction of new algorithm : Least-Change and important improvements to fee estimation and waste computation, cleanups of algorithm structures. This update enhances accuracy and stability in UTXO selection across all algorithms.
🚀 Key Features
✔ Multiple Algorithms
- Knapsack, Branch and Bound, Lowest-Larger, FIFO, and Single-Random-Draw, Least-Change.
- Unified API for switching between strategies to optimize for the best results.
✔ Generic & Extensible
- Works with any UTXO-based chain (Bitcoin, Litecoin, etc.).
- Add custom algorithms via trait implementations.
✔ Improved Waste & Fee Estimation
- More accurate cost-based waste metric that balances transaction fees and UTXO set hygiene.
- Updated change cost computation and fee handling logic.
✔ Well-Documented & Tested
- Full API docs on docs.rs.
- Benchmarks and tests for performance and correctness.
📦 Getting Started
Update your Cargo.toml:
[dependencies]
rust-coinselect = "0.1.6"📚 Quick Example
use rust_coinselect::{
types::{CoinSelectionOpt, ExcessStrategy, OutputGroup},
selectcoin::select_coin,
};
let output_groups = vec![
OutputGroup { value: 1_000_000, weight: 100, input_count: 1, creation_sequence: None },
OutputGroup { value: 2_000_000, weight: 100, input_count: 1, creation_sequence: None },
];
let options = CoinSelectionOpt {
target_value: 1_500_000u64,
target_feerate: 0.5f32,
long_term_feerate: Some(0.3f32),
min_absolute_fee: 1000u64,
base_weight: 72u64,
change_weight: 18u64,
change_cost: 250u64,
avg_input_weight: 300u64,
avg_output_weight: 250u64,
min_change_value: 1_000u64,
excess_strategy: ExcessStrategy::ToChange,
};
if let Ok(selection_output) = select_coin(&output_groups, &options) {
println!("Indexes of the selected utxos = {:?}", selection_output.selected_inputs);
}👉 See a Bitcoin-specific example here.
👉 Explore more in the README and API docs.
💬 Community & Contributions
We’d love your feedback and contributions!
- GitHub Issues: Submit bugs or feature requests
- Discord: Join the discussion
- PRs Welcome! See our Contributing Guide
🙏 Thanks for the Support!
v0.1.6 improves internal logic and lays the groundwork for further optimizations. Thanks to everyone contributing ideas, code, and feedback.