Bitcoin Forum

Other => Beginners & Help => Topic started by: merfakos on December 27, 2012, 03:21:57 PM



Title: bitcoind getbalance out differs from getbalance <account>
Post by: merfakos on December 27, 2012, 03:21:57 PM
Hello,

I have found myself in a weird situation which i can not explain and i would love someone to explain it to me. After trying some pools i decided i prefer above all else p2pool (at least this week..). So i have my bitcoind, run p2pool software and after some time I check my balance and i have this output:

Code:
> bitcoind getbalance
0.95000139
> bitcoind getbalance p2pool
1.16992134

p2pool is an account created by p2pool software in bitcoind.
help getbalance says:

Code:
bitcoind help getbalance
getbalance [account] [minconf=1]
If [account] is not specified, returns the server's total available balance.
If [account] is specified, returns the balance in the account.

So I would expect the first command to return at least something equal to the second command, if not something bigger...

Any idea what is going on ?


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: Largo on December 27, 2012, 03:39:06 PM
If you recieve money through the p2pool account, but send it from another or no account ("") it wont get substracted from the p2pool account.
Thats how it should work after all, if some other account spends it, why should p2pool account's balance go down?


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: merfakos on December 27, 2012, 04:04:37 PM
Maybe I am misunderstanding something here...

Code:
bitcoind getbalance

should according to help return the server's total available balance. I believe this translates to the sum of all accounts. Right ?
So if I have an account with 1.16 BTC and 2 others with 0.0 BTC, the total should be 1.16. Right ?
Cause that is exactly the situation I am in...

Code:
bitcoind listaccounts
{
    "" : 0.00000000,
    "merfakos" : 0.00000000,
    "p2pool" : 1.16992134
}


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: SlickTheNick on December 27, 2012, 04:27:32 PM
Is there any transactions that you have sent out that are awaiting confirmations still? Usually some change gets sent with the transaction, so part of your balance becomes unavailable until that transaction is confirmed


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: merfakos on December 27, 2012, 04:46:52 PM
I have sent out absolute no transactions. That being said... maybe transactions incoming to me have not yet been confirmed enough?  Get balance accepts one argument which is minimum number of confirmations. And at this point in time

Code:
bitcoind getbalance p2pool 88

does indeed match the output of

Code:
bitcoind getbalance

Both outputs btw have changed since my first post since my mining software has obviously not stopped running.

So maybe the default of getbalance command with no account as an argument does not match the default with an account as an argument?
Also maybe that's the point I should have a look at the code...  ;D

Thanks for the help guys.


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: theymos on December 27, 2012, 05:26:10 PM
The balance of an account isn't related to how many bitcoins are currently "stored in" the account. The balance of an account increases when the account receives bitcoins at one of its addresses, but decreases only when you explicitly move bitcoins from the account using something like sendfrom. getbalance without an account is the correct number of bitcoins in your wallet.

The way accounts work often confuses people, but these counter-intuitive behaviors are often useful for simple Bitcoin-accepting websites, which is what the accounts feature was designed for.


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: Gavin Andresen on December 27, 2012, 05:32:22 PM
There is a longstanding issue that might be related:
  https://github.com/bitcoin/bitcoin/issues/172



Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: merfakos on December 27, 2012, 11:08:19 PM
Quote
The balance of an account isn't related to how many bitcoins are currently "stored in" the account.

You lost me here. Please elaborate... or at least RTFM me with a link :-)

Quote
The balance of an account increases when the account receives bitcoins at one of its addresses, but decreases only when you explicitly move bitcoins from the account using something like sendfrom. getbalance without an account is the correct number of bitcoins in your wallet.

This makes sense.


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: merfakos on December 27, 2012, 11:37:45 PM
Quote
There is a longstanding issue that might be related:
  https://github.com/bitcoin/bitcoin/issues/172

Hello Gavin, and thanks for the pointer.

Now from what i see at rpcwallet.cpp, line 519, with today's master (commit 23826f1)

Code:
    if (params[0].get_str() == "*") {
        // Calculate total balance a different way from GetBalance()
        // (GetBalance() sums up all unspent TxOuts)
        // getbalance and getbalance '*' should always return the same number.

And a couple of lines above that
Code:
    if (params.size() == 0)
        return  ValueFromAmount(pwalletMain->GetBalance());

Which is consistent with both the comment and the issue you opened.
So ... I guess that for this not to have been fixed yet it means that either it is an expected/wanted behaviour in which case it might not be bad to document it, or that something bad might happen if it is fixed and suddenly behaviour changes. Right ?


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: CIYAM on December 28, 2012, 12:18:51 AM
Unless you are trying to run a bitcoin service (where an "account" means a "user account") then I would advise you to stay well clear of bitcoin accounts (as they will confuse anyone who understands accounting).

This is from my own personal frustration with trying to use them (now I just don't go there any more and yes I do my own accounting).

:)


Title: Re: bitcoind getbalance out differs from getbalance <account>
Post by: DeathAndTaxes on December 28, 2012, 01:08:04 AM
Unless you are trying to run a bitcoin service (where an "account" means a "user account") then I would advise you to stay well clear of bitcoin accounts (as they will confuse anyone who understands accounting).

This is from my own personal frustration with trying to use them (now I just don't go there any more and yes I do my own accounting).

:)


I would expand it to simply  ... stay away from accounts.  :)

I don't know anyone who has used them effectively in any enterprise.