Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getbalance API call returns incorrect values with account parameter #3002

Closed
pentarh opened this issue Sep 16, 2013 · 13 comments
Closed

getbalance API call returns incorrect values with account parameter #3002

pentarh opened this issue Sep 16, 2013 · 13 comments

Comments

@pentarh
Copy link

pentarh commented Sep 16, 2013

In some reason my wallet accounting broken. I have total 0.1 BTC on wallet and getbalance without params returns correct value.

But when I provide account to this api call (i.e. empty account), it returns incorrect values - greater than overall balance or even negative.

-rescan and -updatewallet - both didn't help. It show absolutely unreal values in listaccounts balances.

[user@localhost ~]$ bin/bitcoind getinfo
{
"version" : 80500,
"protocolversion" : 70001,
"walletversion" : 10500,
"balance" : 0.10000000,
"blocks" : 258337,
"timeoffset" : -1,
"connections" : 8,
"proxy" : "",
"difficulty" : 112628548.66634709,
"testnet" : false,
"keypoololdest" : 1327805721,
"keypoolsize" : 101,
"paytxfee" : 0.00000000,
"errors" : ""
}
[user@localhost ~]$ bin/bitcoind getbalance
0.10000000
[user@localhost ~]$ bin/bitcoind getbalance ''
-20231.03669102
[user@localhost ~]$ bin/bitcoind listaccounts
{
"" : -20231.03669102,
"acc_" : 0.00000000,
"acc_" : 50.00000000,
"acc_" : 0.00000000,
"acc_" : 7.00000000,
"acc_" : 50.00000000,
"acc_" : 5905.00000000,
}
==RAW HTTP==
<--- getbalance[ no params ]
POST / HTTP/1.1
User-Agent: bitcoin-json-rpc/v0.8.5-beta
Host: 127.0.0.1
Content-Type: application/json
Content-Length: 43
Connection: close
Accept: application/json
Authorization: Basic *************

{"method":"getbalance","params":[],"id":1}
------>
HTTP/1.1 200 OK
Date: Mon, 16 Sep 2013 15:15:18 +0000
Connection: close
Content-Length: 42
Content-Type: application/json
Server: bitcoin-json-rpc/v0.8.5-beta

{"result":0.10000000,"error":null,"id":1}

<--- getbalance[ "" ]
POST / HTTP/1.1
User-Agent: bitcoin-json-rpc/v0.8.5-beta
Host: 127.0.0.1
Content-Type: application/json
Content-Length: 45
Connection: close
Accept: application/json
Authorization: Basic *****************

{"method":"getbalance","params":[""],"id":1}
------>
HTTP/1.1 200 OK
Date: Mon, 16 Sep 2013 15:16:15 +0000
Connection: close
Content-Length: 47
Content-Type: application/json
Server: bitcoin-json-rpc/v0.8.5-beta

{"result":-20231.03669102,"error":null,"id":1}

@gmaxwell
Copy link
Contributor

Getbalance is returning the default account "", if you want all accounts use the argument "*". It's possible for an account to have a negative balance if you've spent more from it than you have assigned to that account.

@pentarh
Copy link
Author

pentarh commented Sep 16, 2013

I didn't assigned anything to accounts. This was done automatically by regular bitcoin-qt usage.

How can I recalculate balances?

@gmaxwell
Copy link
Contributor

Just use the move command to move the funds from the accounts back to "".

@pentarh
Copy link
Author

pentarh commented Sep 16, 2013

Thanks. This helped. But anyway I didn't use "move" ever. This mess in accounts appeared by itself.

@gmaxwell
Copy link
Contributor

Assigning labels to addresses in the gui attributes their funds to the various accounts.

@pentarh
Copy link
Author

pentarh commented Sep 16, 2013

Right. But seems it do it wrong.

@Diapolo
Copy link

Diapolo commented Sep 16, 2013

Should accounts match the label everytime? They don't match for me either...

@gavinandresen
Copy link
Contributor

bitcoind accounts and Bitcoin-Qt labels are not designed to be consistent with each other. Use one or the other, not both at the same time.

@Diapolo
Copy link

Diapolo commented Sep 16, 2013

@gavinandresen Well it's at least intersting to have accounts, with names I never set by using Bitcoin-Qt, no? I have no clue about the concept of labels, just asking :).

@laanwj
Copy link
Member

laanwj commented Oct 21, 2013

No, they don't need to match. For historical purposes labels and accounts use the same underlying information in the database but in different ways. I guess that should be changed some day, but doing that and keeping backwards compatibility (neither losing your labels nor accounts) will at least require a lot of testing.

@bitcoinbrisbane
Copy link

Im getting the same error. I have never used labels, always accounts. This seems to return the total inputed. Not taking into account any sends.

@luke-jr
Copy link
Member

luke-jr commented Aug 14, 2014

Are you using sendfrom/sendmany with the account names in question?

@bitcoinbrisbane
Copy link

Thanks for getting back. I just did a send from(account name) and it sent from different addresses in the wallet. Not just the one associated with the account name.

Bushstar pushed a commit to Bushstar/omnicore that referenced this issue Apr 8, 2020
No need to load 25 quorums when we're scanning for the larger quorums which
only have 4 active quorums. This avoids loading thousands of masternode
lists unnecessarily.
Bushstar pushed a commit to Bushstar/omnicore that referenced this issue Apr 8, 2020
No need to load 25 quorums when we're scanning for the larger quorums which
only have 4 active quorums. This avoids loading thousands of masternode
lists unnecessarily.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants