[Wallet] Fix AutoCombineDust and improve setautocombinethreshold#2812
Merged
Fuzzbawls merged 5 commits intoPIVX-Project:masterfrom Mar 8, 2023
Merged
[Wallet] Fix AutoCombineDust and improve setautocombinethreshold#2812Fuzzbawls merged 5 commits intoPIVX-Project:masterfrom
Fuzzbawls merged 5 commits intoPIVX-Project:masterfrom
Conversation
Fuzzbawls
requested changes
Feb 24, 2023
Collaborator
Fuzzbawls
left a comment
There was a problem hiding this comment.
Haven't tested functionality yet, but wanted to point out that it seems that the intentional arbitrary whitespace of the CRPCCommand table in rpcwallet.cpp has gotten mangled in this PR.
Collaborator
|
Also, since you're removing a deprecated RPC command, you'll need to modify |
e2e41da to
c8ecedf
Compare
Author
|
Updated on master |
06ca029 to
63488be
Compare
Collaborator
|
I've tidied this up to remove fixup type commits as well as the merge commit. Avoid including merge commits in PRs. If you need to pull in recent |
Fuzzbawls
approved these changes
Mar 7, 2023
Liquid369
approved these changes
Mar 7, 2023
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.
AutoCombineDust has been bugged since an old PR see (#953 #518).
To make an example of what's happening let's consider for simplicity nAutoCombineThreshold = 100 and let's say that the user has 2 UTXOs one of 90 PIVs and the other of 15 PIVs.
With the current code of AutoCombineDust we will therefore try to send a total of 90+15 = 105 PIVs to ourself, more precisely to avoid the "Insufficient funds" the primary output will contain only the 90% =94.5 PIVs and the remaining 10% = 10.5 PIVs is used to pay fees + sent as a change to ourself. As you can see we end up with two new UTXOs, which are still both smaller than the threshold.
This process is iterated block by block until we end up with a single UTXO which is smaller than the threshold, i.e in this example 5 PIVs will be burn in fees.
Moreover the process of "checking all UTXOs at each block for each address of your wallet" can potentially consume a lot of resources especially if the user has a lot of small UTXOs, therefore I added a new parameter "frequency" which will check for dust every N blocks (where N is the value of frequency), and which is set by default at N = 30.
Finally I removed the old autocombinerewards since it is deprecated and was planned to be removed in v6.0 (https://github.com/PIVX-Project/PIVX/blob/master/doc/release-notes.md)