getbalance gives weird results #5802

issue RHavar opened this issue on February 18, 2015
  1. RHavar commented at 8:50 PM on February 18, 2015: contributor
    bitcoin-cli getbalance "*" 0
    0.12820000
    bitcoin-cli getbalance "" 0
    0.12830000
    

    The * gives less results than "". I guess that's a bug.

    Also weird:

    bitcoin-cli getbalance
    0.12820000
    bitcoin-cli getbalance '*' 1
    0.12810000
    

    When you would expect those two commands are identical. (probably due to unconfirmed change)

  2. dexX7 commented at 3:50 PM on February 20, 2015: contributor

    Hey @RHavar,

    the difference between "*" and "" is that the first one sums all unspent outputs, while the second one considers only those with the account label "". Even though "" appears to be the default label, you probably have at least one with a different label.

    getbalance and getbalance "*" 0 should return the same result. getbalance "*" should return the sum of unspent outputs, but with at least one confirmation.

  3. RHavar commented at 5:41 PM on February 20, 2015: contributor

    @dexX7 I don't think that explains the behavior at all. If you look at my original post, the balance of '_' is _LESS* than the balance of "". If I had two accounts, it would be more. Running bitcoind listaccounts also shows I only have a single account "". Right now everything looks sane, but only because I have no unconfirmed funds/change.

  4. dexX7 commented at 6:19 PM on February 20, 2015: contributor

    @RHavar: account balances can be negative. Would that explain this behavior?

    You'd likely have to use listaccounts 0 to include unconfirmed ones.

    That being said, this call is tagged as deprecated, which might not explain this behavior, but signal to avoid the account system, if possible.

  5. sipa commented at 6:34 PM on February 20, 2015: member

    Accounts can go negative, if you send more from them than to them.

    Accounts have nothing to do with actual coins in the bitcoin transaction sense. They're just bean counters.

    Use listaccounts (iirc) to see all of them.

  6. RHavar commented at 8:22 PM on February 20, 2015: contributor

    To be clear, I'm only using the default account. The problem here is that the rpc call is returning wrong information, and appears to be how it treats unconfirmed transactions/change. The more general API getbalance '*' is not behaving correctly.

  7. laanwj added the label Wallet on Feb 9, 2016
  8. RHavar closed this on Mar 30, 2016

  9. laanwj commented at 8:38 AM on March 30, 2016: member

    We really, really need to get rid of this broken, inconsistent account system. It must be doing more harm than good overall. And all the different ways to get the balance are just ridiculous. I made an API to replace the account system in #7729, that would be a first step.

  10. DrahtBot locked this on Sep 8, 2021
Labels

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:15 UTC

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