[Wallet] Fix stake split output count calculation #2782
Merged
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.
Issue being fixed #1571
The UTXO value of a stake split is sometimes smaller then the stake split threshold
The help description for
setstakesplitthreshold
states:So you would not expect the value of the UTXOs to be lower then the threshold value
This happens because the number of stake split outputs is calculated including the masternode payment
An example (for testnet) with a UTXO with a value of 9992 and the stake split threshold set to 500:
However the staker only receives the stake reward (4) so the total amount after staking will be 9996 which is split across 20 UTXOs with a value of 499.8 each
What was done
The masternode payment is excluded from the stake split output count calculation
How Has This Been Tested
On testnet 2 UTXOs were made (9992 each) and the stake split threshold was set to 500
The expected outcome would be a split across 19 UTXOs with a value of 526.1 each
Before
On stake 20 UTXOs, with a value of 499.8 each, were created
https://testnet.rockdev.org/tx/b966ff04d35ecae596f0dfde3977862268995d63939af3ab90bb172b38c37f20
After
On stake 19 UTXOs, with a value of 526.1 each were created
https://testnet.rockdev.org/tx/e80c79ad1ac41aa096b4613462be348e7a1a4a70755c4943087a83be8865de7a