Bitcoin Forum
May 26, 2024, 05:23:11 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bitcoind getbalance out differs from getbalance <account>  (Read 1568 times)
merfakos (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
December 27, 2012, 03:21:57 PM
 #1

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 ?
Largo
Member
**
Offline Offline

Activity: 112
Merit: 10



View Profile
December 27, 2012, 03:39:06 PM
 #2

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?

merfakos (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
December 27, 2012, 04:04:37 PM
 #3

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
}
SlickTheNick
Full Member
***
Offline Offline

Activity: 220
Merit: 100


View Profile
December 27, 2012, 04:27:32 PM
 #4

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

Looking for a way to get some bitcoins for free? Check out http://earnfreebitcoins.com !
Get easy bitcoins at  https://coincontroller.com?r=eaef398b5 !
merfakos (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
December 27, 2012, 04:46:52 PM
 #5

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...  Grin

Thanks for the help guys.
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5208
Merit: 13013


View Profile
December 27, 2012, 05:26:10 PM
 #6

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.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2217


Chief Scientist


View Profile WWW
December 27, 2012, 05:32:22 PM
 #7

There is a longstanding issue that might be related:
  https://github.com/bitcoin/bitcoin/issues/172


How often do you get the chance to work on a potentially world-changing project?
merfakos (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
December 27, 2012, 11:08:19 PM
 #8

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.
merfakos (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
December 27, 2012, 11:37:45 PM
 #9

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 ?
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
December 28, 2012, 12:18:51 AM
 #10

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).

Smiley

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
December 28, 2012, 01:08:04 AM
 #11

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).

Smiley


I would expand it to simply  ... stay away from accounts.  Smiley

I don't know anyone who has used them effectively in any enterprise.  
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!