From 7157c4941d6e9cc07e44048198a4a39a04dbaa43 Mon Sep 17 00:00:00 2001 From: yancy Date: Wed, 9 Oct 2024 09:40:08 -0500 Subject: [PATCH 1/2] Reset Cargo file for publication --- Cargo.toml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8210390..3adb0a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["bitcoin", "coin-selection", "coin", "coinselection", "utxo"] readme = "README.md" [dependencies] -bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", rev = "894f82e7cc9eb459a297d43e82734621e0824610"} +bitcoin = "0.32.3" rand = {version = "0.8.5", default-features = false, optional = true} [dev-dependencies] @@ -25,12 +25,3 @@ rand = "0.8.5" [[bench]] name = "coin_selection" harness = false - -[patch.crates-io] -bitcoin_hashes = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", rev = "894f82e7cc9eb459a297d43e82734621e0824610" } -base58ck = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", rev = "894f82e7cc9eb459a297d43e82734621e0824610" } -bitcoin-internals = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", rev = "894f82e7cc9eb459a297d43e82734621e0824610" } -bitcoin-io = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", rev = "894f82e7cc9eb459a297d43e82734621e0824610" } -bitcoin-primitives = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", rev = "894f82e7cc9eb459a297d43e82734621e0824610" } -bitcoin-addresses = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", rev = "894f82e7cc9eb459a297d43e82734621e0824610" } -bitcoin-units = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", rev = "894f82e7cc9eb459a297d43e82734621e0824610" } From 1b0b28b52c8b8f5b202dabb55db49b69b1e091d4 Mon Sep 17 00:00:00 2001 From: yancy Date: Wed, 9 Oct 2024 09:56:53 -0500 Subject: [PATCH 2/2] Add temporary patch for Amount::ZERO case If zero does not have a denomination, the amount fails to parse. This has been fixed in a yet to published version of rust-bitcoin. See rust-bitcoin PR 3346. --- src/branch_and_bound.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/branch_and_bound.rs b/src/branch_and_bound.rs index e8d1c24..c1f1b8e 100644 --- a/src/branch_and_bound.rs +++ b/src/branch_and_bound.rs @@ -386,6 +386,17 @@ mod tests { assert_eq!(input_str_list, expected_str_list); } + // This is a temporary patch and can be removed when a new relesae of rust-bitcoin is + // published. See: https://github.com/rust-bitcoin/rust-bitcoin/pull/3346 + fn amount_from_str_patch(amount: &str) -> Amount { + let a = Amount::from_str(amount); + + match a { + Ok(a) => a, + Err(_) => Amount::ZERO + } + } + fn assert_coin_select_params(p: &ParamsStr, expected_inputs: &[&str]) { let fee_rate = p.fee_rate.parse::().unwrap(); // would be nice if FeeRate had // from_str like Amount::from_str() @@ -394,7 +405,7 @@ mod tests { let expected_str_list: Vec<_> = expected_inputs.iter().map(|s| Amount::from_str(s).unwrap().to_string()).collect(); let target = Amount::from_str(p.target).unwrap(); - let cost_of_change = Amount::from_str(p.cost_of_change).unwrap(); + let cost_of_change = amount_from_str_patch(p.cost_of_change); let fee_rate = FeeRate::from_sat_per_kwu(fee_rate); let lt_fee_rate = FeeRate::from_sat_per_kwu(lt_fee_rate);