nochowderforyou / clams

Clam Project
MIT License
62 stars 58 forks source link

listaccounts values don't sum to the balance #186

Closed dooglus closed 9 years ago

dooglus commented 9 years ago

The listaccounts balances (visible when using enableaccounts=1) generally sum to a negative number, since when the wallet stakes, the stake isn't credited to any account, but when the staked value is spent, it is debited from an account.

To fix this, we need to credit staking rewards to an account.

I figure some applications may want to credit staking rewards to the account which owns the address that staked a block, whereas other would prefer the reward to be credited to the "" account.

I propose a new flag:

creditstakeaddressaccounts=1

which causes rewards to go to the accounts which own the address that staked, with the default being for the "" account to get all rewards.

The flag name is ugly. Any better suggestions?

Kefkius commented 9 years ago

How about creditstaketoaccounts[=0], or usedefaultstakeaccount[=1]?

Or for a negative one, nodefaultstakeaccount[=0]?

dooglus commented 9 years ago

creditstaketoaccounts isn't bad.

dooglus commented 9 years ago

I tested committed a change that implements the flag. It seems to work well.

$ clamd listaccounts | grep -v " 0[.]00000000" # with creditstakeaddressaccounts=1
{
    "" : -2783.31329042,
    "1" : 292.14338700,
    "1004771" : 7.04160000,
    ...
} # (a bunch of numbers which sum to the wallet's balance of 0.00139687)

$ clamd listaccounts | grep -v " 0[.]00000000" # with creditstakeaddressaccounts=0
{
    "704586" : 0.00139687,
}

$ clamd listaccounts | grep -v " 0[.]00000000" # with nothing
{
    "704586" : 0.00139687,
}
dooglus commented 9 years ago

I went with creditstakestoaccounts (added an 's' to 'stake') and merged to master branch.