wallet-core: Fix pick_notes function for selecting the input-notes for a transaction #2852
+174
−87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The function
pick_notes
selects up to 4 input notes to be included in a phoenix-transaction.With a spendable value lower than the total value of the notes, and the transaction target value higher than the spendable,
pick_notes
still returned 4 input-notes even though the transaction-costs weren't covered with those four notes.To give an example:
Let's assume we have 5 unspent notes each with a value of 2 DUSK.
This means the max spendable is 8 DUSK (4 * 2).
For a transaction that costs 9 DUSK,
pick_notes
should return an empty list indicating that there is no combination of the input-notes where the transaction-costs is covered.The old behavior of
pick_notes
however was to still return a list of 4 input-notes, even though the values of those notes combined was lower than the transaction-cost.Such a transaction isn't spendable (its circuit is invalid) so no harm was done, but the behavior is still not desirable.