wallet: ensure VSP payment doesn't create unmixable change#2595
Open
matthawkins90 wants to merge 2 commits intodecred:masterfrom
Open
wallet: ensure VSP payment doesn't create unmixable change#2595matthawkins90 wants to merge 2 commits intodecred:masterfrom
matthawkins90 wants to merge 2 commits intodecred:masterfrom
Conversation
78bd064 to
8839841
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Buying tickets through a VSP had the possibility of creating outputs that were larger than dust, but not larger than the
smallestMixChange. This change is toxic (since it is unmixable), and it also is linked to the ticket purchase. In practice, it's just more annoying than anything, because the wallet's unmixed balance will never reach zero.Since
ReserveOutputsForAmountis a public api, I createdreserveOutputsForAmountto do the same thing, but also addminChangeas an argument.Then,
CreateVspPaymentcalls that new function, and requests inputs totaling at least (fee + minMixableChange + estTxFee).Edge Case Note
If this function uses a single input, the math works fine. However, if multiple inputs are used and they total the EXACT target (zero buffer), the actual txFee for two inputs will be higher than the estimated fee rate, and so we'll still end up with unmixable change.
I considered adding a log somewhere like:
but I figured that this might be an extreme edge case, and might be completely unnecessary?