Open pgerzani opened 3 years ago
@pgerzani
The latest changes are implemented in https://github.com/projectpai/paicoin/tree/feature/develop/balance-inconsistencies.
I removed the vote and revocation inputs from the debit calculations, since they should not in principle affect the wallet balance. In case of stake transactions, it is the tickets that spend funds and the vote and revocations that bring funds, from the wallet perspective. However, if this logic is not correct, please let me know.
These changes also contain some new values in the getwalletinfo
response, for available_balance
and legacy_balance
.
The balance in getbalance
(without any parameter) and getwalletinfo
->balance
should be the same.
listaccounts
uses a different calculation method and may diverge from the values above.
totalsubsidy
in getstakeinfo
should be the sum of all ticket stake outputs that have been used for voting. This is not the sum of funds being staked by all the tickets. Maybe this is a misnomer, something like totalvotedstake
would be better. Please advise.
I also created this document to detail the various balance calculations as they are currently implemented in the code: https://docs.google.com/document/d/18dUzqxmKDA2th5HUgOJuQUCKQyBbUKBuelpdHx9UlvQ.
@sebastianrusu It does not appear that this resolved the issue, at least not the bulk of what we were seeing. @mharvilla has agreed to provide you with the Lanier AI wallet which has ~1.5M funds that appear to be missing. I will connect with you to provide it.
Mark and I both have wallets that only do staking and voting transactions. In both cases, they are showing odd values for the balance that don't seem to sum up to what was sent to the wallet.
Mark's wallet:
getbalance
returns 204,074staked_balance
fromgetwalletinfo
shows 520,054getstakeinfo
shows that the wallet owns 41 immature tickets. At an average cost of 12,684, that is 520,044 so that makes sense with feesgetstakeinfo
showsownmempooltix
as 0 which we assume means that there are no mempool transactions hanging out there? So, 1,730,000 - (204,074 + 520,054) results in a discrepancy of ~1M PAI Another odd thing ispaicoin-cli getbalance "*" 6
returns a value of 1.73M PAI. Is this due to the tickets being immature?Staker's wallet:
getbalance
returns 12,250staked_balance
fromgetwalletinfo
shows: 1,391,398getstakeinfo
shows 0 forownmempooltix
and 4956 forunspent
with 55007 fortotalsubsidy
So, again we have a substantial disparity: 3,300,000 - (1,391,398 + 12,250) = 1.896M PAIpaicoin-cli getbalance "*" 6
returns 3,291,638 PAI which makes sense for the full total and matches the value frompaicoin-cli listaccounts
In order to identify the source of these discrepancies, I was thinking we should first update the functional tests to ensure they are covered. The following balances I would expect to all match:
getbalance
getwalletinfo
balance
attributelistaccounts
and likewise:
getstakeinfo
attributetotalsubsidy
should be >= thangetwalletinfo
stakedbalance
if I understand it correctly?