Merge pull request #6458 from sellout/safer-note-selection
Make pool selection order more flexible
This commit is contained in:
commit
62a0e78e4a
|
@ -8063,9 +8063,6 @@ bool SpendableInputs::LimitToAmount(
|
||||||
// Fully shielded.
|
// Fully shielded.
|
||||||
selectionOrder = {
|
selectionOrder = {
|
||||||
OutputPool::Orchard,
|
OutputPool::Orchard,
|
||||||
// Pools below here are erased.
|
|
||||||
OutputPool::Transparent,
|
|
||||||
OutputPool::Sapling,
|
|
||||||
};
|
};
|
||||||
} else if (
|
} else if (
|
||||||
recipientPools.count(OutputPool::Transparent) &&
|
recipientPools.count(OutputPool::Transparent) &&
|
||||||
|
@ -8075,9 +8072,6 @@ bool SpendableInputs::LimitToAmount(
|
||||||
// Fewer pools.
|
// Fewer pools.
|
||||||
selectionOrder = {
|
selectionOrder = {
|
||||||
OutputPool::Orchard,
|
OutputPool::Orchard,
|
||||||
// Pools below here are erased.
|
|
||||||
OutputPool::Transparent,
|
|
||||||
OutputPool::Sapling,
|
|
||||||
};
|
};
|
||||||
} else if (wouldSuffice(availableSapling + availableOrchard)) {
|
} else if (wouldSuffice(availableSapling + availableOrchard)) {
|
||||||
// Hide sender.
|
// Hide sender.
|
||||||
|
@ -8087,8 +8081,6 @@ bool SpendableInputs::LimitToAmount(
|
||||||
selectionOrder = {
|
selectionOrder = {
|
||||||
OutputPool::Sapling,
|
OutputPool::Sapling,
|
||||||
OutputPool::Orchard,
|
OutputPool::Orchard,
|
||||||
// Pools below here are erased.
|
|
||||||
OutputPool::Transparent,
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Opportunistic shielding.
|
// Opportunistic shielding.
|
||||||
|
@ -8100,14 +8092,25 @@ bool SpendableInputs::LimitToAmount(
|
||||||
opportunisticShielding = true;
|
opportunisticShielding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we provided a total selection order (so that all unselected notes
|
// Erase all notes and coins from pools that aren’t used in selection.
|
||||||
// and coins are erased).
|
|
||||||
for (auto pool : available) {
|
for (auto pool : available) {
|
||||||
bool poolIsPresent = false;
|
bool poolIsPresent = false;
|
||||||
for (auto entry : selectionOrder) {
|
for (auto entry : selectionOrder) {
|
||||||
poolIsPresent |= entry == pool;
|
poolIsPresent |= entry == pool;
|
||||||
}
|
}
|
||||||
assert(poolIsPresent);
|
if (!poolIsPresent) {
|
||||||
|
switch (pool) {
|
||||||
|
case OutputPool::Transparent:
|
||||||
|
utxos.clear();
|
||||||
|
break;
|
||||||
|
case OutputPool::Sapling:
|
||||||
|
saplingNoteEntries.clear();
|
||||||
|
break;
|
||||||
|
case OutputPool::Orchard:
|
||||||
|
orchardNoteMetadata.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, select the remaining notes and coins based on this order.
|
// Finally, select the remaining notes and coins based on this order.
|
||||||
|
|
Loading…
Reference in New Issue