zcash_client_sqlite: Ensure that we only exclude the correct notes from selection.

This commit is contained in:
Kris Nuttycombe 2024-03-10 15:05:33 -06:00 committed by Jack Grigg
parent 44f5a55b92
commit 6086774b9b
2 changed files with 8 additions and 2 deletions

View File

@ -319,7 +319,10 @@ pub(crate) fn select_spendable_orchard_notes<P: consensus::Parameters>(
FROM (SELECT * from eligible WHERE so_far >= :target_value LIMIT 1)",
)?;
let excluded: Vec<Value> = exclude.iter().map(|n| Value::from(n.1)).collect();
let excluded: Vec<Value> = exclude
.iter()
.filter_map(|n| matches!(n.0, ShieldedProtocol::Orchard).then(|| Value::from(n.1)))
.collect();
let excluded_ptr = Rc::new(excluded);
let notes = stmt_select_notes.query_and_then(

View File

@ -317,7 +317,10 @@ pub(crate) fn select_spendable_sapling_notes<P: consensus::Parameters>(
FROM (SELECT * from eligible WHERE so_far >= :target_value LIMIT 1)",
)?;
let excluded: Vec<Value> = exclude.iter().map(|n| Value::from(n.1)).collect();
let excluded: Vec<Value> = exclude
.iter()
.filter_map(|n| matches!(n.0, ShieldedProtocol::Sapling).then(|| Value::from(n.1)))
.collect();
let excluded_ptr = Rc::new(excluded);
let notes = stmt_select_notes.query_and_then(