From 6086774b9bba0d80828e2a678fb33aea71737f27 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Sun, 10 Mar 2024 15:05:33 -0600 Subject: [PATCH] zcash_client_sqlite: Ensure that we only exclude the correct notes from selection. --- zcash_client_sqlite/src/wallet/orchard.rs | 5 ++++- zcash_client_sqlite/src/wallet/sapling.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/zcash_client_sqlite/src/wallet/orchard.rs b/zcash_client_sqlite/src/wallet/orchard.rs index e14f1ff35..dbdc80bd8 100644 --- a/zcash_client_sqlite/src/wallet/orchard.rs +++ b/zcash_client_sqlite/src/wallet/orchard.rs @@ -319,7 +319,10 @@ pub(crate) fn select_spendable_orchard_notes( FROM (SELECT * from eligible WHERE so_far >= :target_value LIMIT 1)", )?; - let excluded: Vec = exclude.iter().map(|n| Value::from(n.1)).collect(); + let excluded: Vec = 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( diff --git a/zcash_client_sqlite/src/wallet/sapling.rs b/zcash_client_sqlite/src/wallet/sapling.rs index ed748b48b..2649ff436 100644 --- a/zcash_client_sqlite/src/wallet/sapling.rs +++ b/zcash_client_sqlite/src/wallet/sapling.rs @@ -317,7 +317,10 @@ pub(crate) fn select_spendable_sapling_notes( FROM (SELECT * from eligible WHERE so_far >= :target_value LIMIT 1)", )?; - let excluded: Vec = exclude.iter().map(|n| Value::from(n.1)).collect(); + let excluded: Vec = 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(