Hello everyone,
In Mint we had a bug that affects "getbalance accountname" RPC calls since PoS phase started. This was a bug only for wallet's account keeping functions -- overall balance of the wallet was always correct. A fix for the bug is available on GitHub. I think the same bug may be affecting other PoS coins. Thanks to drakoin for making me announce this here.
Let me explain you the problem;
There are 2 ways to calculate the balance in the wallet, one sums unspent TxOuts and gives a single balance, and the other tries to bind minted coins / received coins / sent coins with accounts. Normally, result of these 2 methods should exactly match. In our case, they didn't (and I suspect other PoS coins to have the same problem). This is similar to the bugs CryptoRush experienced with BC when keeping records of customer balances in wallet's account functionality (it may even be the same bug, I don't know).
This was my problem after some PoS minting:
00:20:17 listaccounts --> Summing these don't match wallet's balance
00:20:17 {
"" : -9970744.49303600,
"account1" : 0.00000000,
"account2" : 17487916.06958000,
"account3" : 200000.00000000,
"account4" : 1250000.00000000,
"account5" : 5035.17977500,
"account6" : 4984.06119900,
"account7" : 3450.50390700,
"account8" : 88294.56108000
}
00:20:57 getbalance *
00:20:57 9068935.88250500 --> This is wrong, but consistent with listaccounts sum
00:21:12 getbalance '*'
00:21:12 9068935.88250500
00:21:00 getbalance
00:21:00 8428756.53745800 --> This is the correct wallet balance
00:21:02 getbalance ""
00:21:02 -9970744.49303600 --> This is wrong, but consistent with listaccounts
The patch can be obtained from the following github commit. Note that unfortunately it's committed together with another change that disables PoW. Only changes in wallet.h, wallet.cpp, rpcwallet.cpp, main.h are relevant.
https://github.com/mintcoinproject/mintcoin/commit/dad79713d4172a569238de1b736abfbf307acfbdStill, even with this patch, I wouldn't trust wallet's per-account functions to keep customers' finance information (there are more information that should be given in PoS wallets' RPC calls for proper bookkeeping, such as listing of per account stakes, mature/immature coins, etc), but I believe this is a step in the right direction. I will be very happy to receive some feedback about the patch and if it affects other PoS coins.
These are the testing steps to see if another PoS coin is affected :
Test-1: These two should return the same amount
Test-2: listaccounts output and individual account getbalances should match. "" is a special account, has to be checked.
listaccounts
getbalance ""
getbalance some_account_with_some_spent_and_some_minted_coints
Test-3: getbalance * and sum of listaccounts should match
thanks to drakoin