getbalance API call returns incorrect values with account parameter #3002

issue pentarh opened this issue on September 16, 2013
  1. pentarh commented at 3:25 PM on September 16, 2013: none

    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}

  2. gmaxwell commented at 4:25 PM on September 16, 2013: 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.

  3. pentarh commented at 4:31 PM on September 16, 2013: none

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

    How can I recalculate balances?

  4. gmaxwell commented at 4:33 PM on September 16, 2013: contributor

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

  5. pentarh commented at 4:40 PM on September 16, 2013: none

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

  6. gmaxwell commented at 4:44 PM on September 16, 2013: contributor

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

  7. pentarh commented at 4:45 PM on September 16, 2013: none

    Right. But seems it do it wrong.

  8. Diapolo commented at 9:15 PM on September 16, 2013: none

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

  9. gavinandresen commented at 9:18 PM on September 16, 2013: 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.

  10. Diapolo commented at 9:22 PM on September 16, 2013: none

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

  11. laanwj commented at 11:26 AM on October 21, 2013: member

    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.

  12. laanwj added the label RPC on Jul 31, 2014
  13. laanwj closed this on Jul 31, 2014

  14. bitcoinbrisbane commented at 11:45 PM on August 13, 2014: none

    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.

  15. luke-jr commented at 12:32 AM on August 14, 2014: member

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

  16. bitcoinbrisbane commented at 3:47 AM on August 17, 2014: none

    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.

  17. Bushstar referenced this in commit 09b017fc53 on Apr 8, 2020
  18. Bushstar referenced this in commit 8d763c1440 on Apr 8, 2020
  19. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me