Skip to content

Commit

Permalink
Add single random draw selection algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
yancyribbens committed Aug 4, 2023
1 parent 776648d commit 81297e2
Show file tree
Hide file tree
Showing 6 changed files with 452 additions and 219 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.1.0 - 2022-12-17

* Initial release.

# 0.2.0 - 2023-06-03

- Add Single Random Draw module and a basic error type.
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ homepage = "https://github.com/rust-bitcoin/rust-bitcoin-coin-selection/"
license = "CC0-1.0"
name = "rust-bitcoin-coin-selection"
repository = "https://github.com/rust-bitcoin/rust-bitcoin-coin-selection/"
version = "0.1.0"
version = "0.2.0"
# documentation = "https://docs.rs/bitcoin-coin-selection/"
description = "Libary providing utility functions to efficiently select a set of UTXOs."
keywords = ["crypto", "bitcoin"]
readme = "README.md"

[dependencies]
bitcoin = { git="https://github.com/yancyribbens/rust-bitcoin", branch="master" }
rand = {version = "0.8.5", default-features = false, optional = true}

[dev-dependencies]
rust-bitcoin-coin-selection = {path = ".", features = ["rand"]}
rand = "0.8.5"

[patch.crates-io]
bitcoin_hashes = { git="https://github.com/yancyribbens/rust-bitcoin.git" }
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.41.1"
msrv = "1.48.0"
26 changes: 26 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// Error types.
use bitcoin::FeeRate;
use bitcoin::Weight;
use std::error::Error as E;
use std::fmt;

#[derive(Debug)]
pub enum Error {
Multiplication(Weight, FeeRate),
SizeMismatch(usize, usize),
}

impl E for Error {}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::Multiplication(weight, fee_rate) => {
write!(f, "{} * {} exceeds u64 Max", weight, fee_rate)
},
Error::SizeMismatch(input_count, output_count) => {
write!(f, "the number of inputs: {} and outputs: {} does not match", input_count, output_count)
}
}
}
}
Loading

0 comments on commit 81297e2

Please sign in to comment.