Skip to content

Releases: citadel-tech/rust-coinselect

v0.1.6: New Selection Algorithm & fixed Waste, Fee Handling

23 Jul 15:54
abe2a56

Choose a tag to compare

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!


🙏 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.

A Blockchain-Agnostic Coin Selection Library in Rust

30 Jun 12:10
674854c

Choose a tag to compare

rust-coinselect v0.1.5 – A Blockchain-Agnostic Coin Selection Library in Rust

First Public Release | GitHub | docs.rs | crates.io

We’re thrilled to announce the first stable release of rust-coinselect, a high-performance, blockchain-agnostic UTXO selection library written in Rust. Designed for wallets and blockchain nodes, it offers production-ready algorithms with a clean, extensible API.


🚀 Key Features

Multiple Algorithms

  • Knapsack, Branch and Bound, Lowest Larger, FIFO, and Single-Random-Draw.
  • 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.

Waste-Metric Optimization

  • Balances transaction fees and long-term wallet efficiency using a cost-based waste metric.
  • Optimizes for least change and least number of inputs

Well-Documented & Tested

  • Full API docs on docs.rs.
  • Benchmarks and unit tests for reliability.

📦 Getting Started

Add to Cargo.toml:

[dependencies]
rust-coinselect = "0.1.5"

📚 Quick Example

use rust_coinselect::{
    types::{CoinSelectionOpt, ExcessStrategy, OutputGroup},
    selectcoin::select_coin,
};

// UTXOs converted to OutputGroups
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 bitcoin specific example given here.

👉 See more in the README or API docs.


💬 Community & Contributions

We welcome feedback, bug reports, and contributions!


🙏 Thank You!

This release is just the beginning. We’re excited to see how the community uses and improves rust-coinselect!

🔗 Links: