From 27ddcd2a516deec143be1895c1bbb27aea149619 Mon Sep 17 00:00:00 2001 From: yancy Date: Sat, 14 Dec 2024 17:02:07 -0600 Subject: [PATCH] wip --- benches/coin_selection.rs | 1 + src/coin_grinder.rs | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/benches/coin_selection.rs b/benches/coin_selection.rs index c9f2d9dc..914fc95e 100644 --- a/benches/coin_selection.rs +++ b/benches/coin_selection.rs @@ -11,6 +11,7 @@ pub struct Utxo { impl WeightedUtxo for Utxo { fn satisfaction_weight(&self) -> Weight { self.satisfaction_weight } + fn weight(&self) -> Weight { Weight::ZERO } fn value(&self) -> Amount { self.output.value } } diff --git a/src/coin_grinder.rs b/src/coin_grinder.rs index 19a5f0ba..f68b636a 100644 --- a/src/coin_grinder.rs +++ b/src/coin_grinder.rs @@ -9,8 +9,7 @@ /// # Parameters /// /// * target: Target spend `Amount` -/// * change_target: A bound on the `Amount` to increase target by with which to create a change -/// output. +/// * change_target: A bound on the `Amount` to increase target by with which to create a change output. /// * max_selection_weight: Maximum allowable selection weight. /// * fee_rate: Needed to calculate the effective_value. /// * weighted_utxos: The candidate Weighted UTXOs from which to choose a selection from @@ -53,7 +52,6 @@ use bitcoin::amount::CheckedSum; /// - Not enough potential amount to meet the target, etc /// - Target Amount is zero (no match possible) /// - UTXO space was searched succefully however no match was found - // The sum of UTXO amounts after this UTXO index, e.g. lookahead[5] = Σ(UTXO[6+].amount) fn build_lookahead(lookahead: Vec<(Amount, &Utxo)>, available_value: Amount) -> Vec{ lookahead.iter().map(|(e, _w)| e).scan(available_value, |state, &u| { @@ -318,7 +316,7 @@ mod tests { let eff_values: Vec<(Amount, &Utxo)> = calc_effective_values(&utxos, FeeRate::ZERO); let min_group_weight = build_min_group_weight(eff_values.clone()); - let expect: Vec = vec![ + let expect: Vec = [ 4u64, 4u64, 8u64, @@ -341,7 +339,7 @@ mod tests { let available_value = Amount::from_str("26 sats").unwrap(); let lookahead = build_lookahead(eff_values, available_value); - let expect: Vec = vec![ + let expect: Vec = [ "16 sats", "9 sats", "4 sats",