Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wallet] Fix stake split output count calculation #2782

Merged
merged 1 commit into from
Feb 12, 2023

Conversation

PeterL73
Copy link

@PeterL73 PeterL73 commented Nov 11, 2022

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:

This will set the stake-split threshold value.
Whenever a successful stake is found, the stake amount is split across as many outputs 
(each with a value higher than the threshold) as possible.

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:

9992 + 10 (total block reward: 4 stake reward + 6 masternode payment) = 10002
10002 / 500 = 20.004
(int) 20.004 = 20

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

9992 + 4 (stake reward) = 9996
9996 / 500 = 19.992
(int) 19.992 = 19
9996 / 19 = 526.1

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

Copy link

@panleone panleone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK:
Good catch and straightforward fix

Copy link
Member

@Liquid369 Liquid369 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 6e51d38

Wish I has tested this abit sooner sorry for the delay!

Copy link
Member

@Duddino Duddino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6e51d38

@Fuzzbawls Fuzzbawls merged commit 0bd96c8 into PIVX-Project:master Feb 12, 2023
@Fuzzbawls Fuzzbawls added this to the 5.6.0 milestone Feb 6, 2024
@Fuzzbawls Fuzzbawls changed the title Wallet: Fix stake split output count calculation [Wallet] Fix stake split output count calculation Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Bug] Stake split splitted an UTXO on lower UTXOs than it was set
5 participants