Skip to content

Commit

Permalink
draft: add coin-grinder
Browse files Browse the repository at this point in the history
  • Loading branch information
yancyribbens committed Dec 14, 2024
1 parent 193d9cc commit 1452fca
Show file tree
Hide file tree
Showing 5 changed files with 431 additions and 11 deletions.
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["bitcoin", "coin-selection", "coin", "coinselection", "utxo"]
readme = "README.md"

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

[dev-dependencies]
Expand All @@ -25,3 +25,13 @@ rand = "0.8.5"
[[bench]]
name = "coin_selection"
harness = false


[patch.crates-io]
bitcoin_hashes = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git" }
base58ck = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git" }
bitcoin-internals = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git" }
bitcoin-io = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git" }
bitcoin-primitives = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git" }
bitcoin-addresses = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git" }
bitcoin-units = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git" }
10 changes: 5 additions & 5 deletions src/branch_and_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ mod tests {
let mut pool = vec![];

for a in amts {
let utxo = build_utxo(a, Weight::ZERO);
let utxo = build_utxo(a, Weight::ZERO, Weight::ZERO);
pool.push(utxo);
}

Expand Down Expand Up @@ -400,7 +400,7 @@ mod tests {
.weighted_utxos
.iter()
.map(|s| Amount::from_str(s).unwrap())
.map(|a| build_utxo(a, Weight::ZERO))
.map(|a| build_utxo(a, Weight::ZERO, Weight::ZERO))
.collect();

let iter = select_coins_bnb(target, cost_of_change, fee_rate, lt_fee_rate, &w_utxos);
Expand Down Expand Up @@ -639,7 +639,7 @@ mod tests {
.map(|a| Amount::from_sat(a as u64))
.collect();

let pool: Vec<_> = amts.into_iter().map(|a| build_utxo(a, Weight::ZERO)).collect();
let pool: Vec<_> = amts.into_iter().map(|a| build_utxo(a, Weight::ZERO, Weight::ZERO)).collect();

let list = select_coins_bnb(target, Amount::ONE_SAT, FeeRate::ZERO, FeeRate::ZERO, &pool);

Expand All @@ -658,7 +658,7 @@ mod tests {
});

let amts: Vec<_> = vals.map(Amount::from_sat).collect();
let pool: Vec<_> = amts.into_iter().map(|a| build_utxo(a, Weight::ZERO)).collect();
let pool: Vec<_> = amts.into_iter().map(|a| build_utxo(a, Weight::ZERO, Weight::ZERO)).collect();

let list = select_coins_bnb(
Amount::from_sat(target),
Expand Down Expand Up @@ -687,7 +687,7 @@ mod tests {

// Add a value that will match the target before iteration exhaustion occurs.
amts.push(Amount::from_sat(target));
let pool: Vec<_> = amts.into_iter().map(|a| build_utxo(a, Weight::ZERO)).collect();
let pool: Vec<_> = amts.into_iter().map(|a| build_utxo(a, Weight::ZERO, Weight::ZERO)).collect();

let mut list = select_coins_bnb(
Amount::from_sat(target),
Expand Down
Loading

0 comments on commit 1452fca

Please sign in to comment.