Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: MangoJ on July 22, 2013, 11:36:47 PM



Title: Bitcoin API "getbalance" for a spesific account is invalid.
Post by: MangoJ on July 22, 2013, 11:36:47 PM
Hello.

I am testing bitcoind on my server and I noticed some API calls are wrong.
For example "getaccountaddress" is listed to "Returns the current bitcoin address for receiving payments to this account. "
However it creates a NEW address in your wallet and gives it the same account name.  This cannot be right.
But I dont care about that one.

I do care about having multiple "accounts" and getting the current ~available~ balance.
Bitcoind API seems INCAPABLE of telling you the current available balance for an account.
"Getbalance" will only show the available balance for your entire wallet, OR All the coin you have EVER received for a specific account, but not the current balance for a specific account.

I have looked on google to see other people with the same problem and no solution.
Yet other websites can take my bitcoin address and tell me how much I have in my account currently.

How can I get the current balance for one of the many different "accounts"?

(Also the "move" API function does nothing at all.)


Title: Re: Bitcoin API "getbalance" for a spesific account is invalid.
Post by: MangoJ on July 22, 2013, 11:56:53 PM
For example... the following API/PHP code:
Quote
$main='1CbXKAKwV1173nNoopT5dFbwin2us9kJo5';
print("Current Balance: ".$bitcoin->getbalance()."<br>");
$accountname="main";
print_r($bitcoin->getbalance($accountname,0)."<br>");
print_r($bitcoin->getbalance($accountname,1)."<br>");
print_r($bitcoin->getbalance($accountname,10)."<br>");
print_r($bitcoin->getbalance($accountname,100)."<br>");
print_r($bitcoin->getbalance($accountname,1000)."<br>");
print_r($bitcoin->getbalance($accountname,10000)."<br>");
print_r($bitcoin->getbalance($accountname,100000)."<br>");
print_r($bitcoin->getbalance($accountname,1000000)."<br>");
print_r($bitcoin->getbalance($accountname,10000000)."<br>");
print_r($bitcoin->getbalance($accountname,99999999999)."<br>");
print_r($bitcoin->getbalance($accountname,999999999999)."<br>");
print_r($bitcoin->getbalance($accountname,9999999999999)."<br>");

will result in a strange inconsistent:
Quote
Current Balance: 0.35959594
53.11832942
53.11832942
53.11832942
53.09431754
52.95047184
41.96723348
0.3664962
0.3664962
0.3664962
0.3664962
53.11832942
0.3664962

Why is it uneven?
Why does the number of verifications more or less return different account balances?
My TRUE current balance is 0.35959594


Title: Re: Bitcoin API "getbalance" for a spesific account is invalid.
Post by: MangoJ on July 23, 2013, 04:16:00 AM
Solved. Move function does work, I had odd numbers spread out all over, negative numbers etc.


Title: Re: Bitcoin API "getbalance" for a spesific account is invalid.
Post by: kjj on July 27, 2013, 04:41:30 AM
The basic problem is that accounts and addresses do not in any way work the way you think they work.

Bitcoin accounts have no concept of "available".  They aren't for that.  The wallet as a whole has "available", but accounts do not.