rust-coinselect
A blockchain-agnostic coin selection library built in Rust.
Technical Scope
The library performs coin selection via various algorithms through a well-documented API. The API is generic in nature and does not assume any structure or method specific to bitcoin. It is designed to be used by any UTXO-based blockchain.
The following algorithms are implemented from scratch in Rust:
- Knapsack
- Branch and Bound
- Lowest Larger
- First-In-First-Out
- Single-Random-Draw
The library has individual APIs for each algorithm. It also has a wrapper API select_coin() which performs selection via each algorithm and return the selection result with the least waste metric.
Bitcoin specific example is given here.
An example usage is given below
let utxos: = vec!; // List of the available UTXOs
let output_groups: = utxos.iter.map.collect;
let options = CoinSelectionOpt ;
let selection_output = select_coin;
println!;
println!;
let selected_utxos: = selection_output.iter.map.collect;
The convert_utxo_to_output logic should be implemented by the user for the respective blockchain protocol.
Note that we can group multiple utxos into a single [OutputGroup].
Other characteristics of the library:
- Well-documented code, helpful in understanding coin selection theory.
- Minimal possible dependency footprint.
- Minimal possible MSRV (Minimum Supported Rust Version).
Community
The dev community gathers in a small corner of Discord here (say hello if you drop there from this readme).
Dev discussions predominantly happen via FOSS (Free and Open-Source Software) best practices, and by using GitHub as the Community Forum.
The Issues, PRs, and Discussions are where all the heavy lifting happens.