zcash_client_sqlite: Fix incorrect input selection filtering when sending to transparent.
The "avoid pool crossing" conditions in not selection were erroneously not taking into account the need to pay transparent outputs.
This commit is contained in:
parent
a58355f697
commit
d431889560
|
@ -394,20 +394,25 @@ where
|
||||||
// of funds selected is strictly increasing. The loop will either return a successful
|
// of funds selected is strictly increasing. The loop will either return a successful
|
||||||
// result or the wallet will eventually run out of funds to select.
|
// result or the wallet will eventually run out of funds to select.
|
||||||
loop {
|
loop {
|
||||||
|
#[cfg(not(feature = "orchard"))]
|
||||||
|
let use_sapling = true;
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
|
let (use_sapling, use_orchard) = {
|
||||||
let (sapling_input_total, orchard_input_total) = (
|
let (sapling_input_total, orchard_input_total) = (
|
||||||
shielded_inputs.sapling_value()?,
|
shielded_inputs.sapling_value()?,
|
||||||
shielded_inputs.orchard_value()?,
|
shielded_inputs.orchard_value()?,
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(not(feature = "orchard"))]
|
// Use Sapling inputs if there are no Orchard outputs or there are not sufficient
|
||||||
let orchard_input_total = NonNegativeAmount::ZERO;
|
// Orchard outputs to cover the amount required.
|
||||||
|
|
||||||
let use_sapling =
|
let use_sapling =
|
||||||
!(sapling_outputs.is_empty() && orchard_input_total >= amount_required);
|
orchard_outputs.is_empty() || amount_required > orchard_input_total;
|
||||||
#[cfg(feature = "orchard")]
|
// Use Orchard inputs if there are insufficient Sapling funds to cover the amount
|
||||||
let use_orchard =
|
// reqiuired.
|
||||||
!(orchard_outputs.is_empty() && sapling_input_total >= amount_required);
|
let use_orchard = !use_sapling || amount_required > sapling_input_total;
|
||||||
|
|
||||||
|
(use_sapling, use_orchard)
|
||||||
|
};
|
||||||
|
|
||||||
let sapling_inputs = if use_sapling {
|
let sapling_inputs = if use_sapling {
|
||||||
shielded_inputs
|
shielded_inputs
|
||||||
|
|
Loading…
Reference in New Issue