listtransactions and getbalance discrepancy #13559

issue kallewoof opened this issue on June 28, 2018
  1. kallewoof commented at 6:28 AM on June 28, 2018: member

    Another user noted that bitcoin-cli listtransactions "*" 99999 and getbalance "*" (these days simply getbalance) are not giving the same amounts when summed together.

    I noticed the same behavior on a node I have access to, but could not reproduce this on regtest despite sending back and forth multiple times between two nodes.

    To tally the listtransactions amounts:

    bitcoin-cli listtransactions "*" 99999|jq -r ".[].amount, .[].fee" | grep -v null | perl -nle '$sum += $_ } END { print $sum'
    

    Compare this to bitcoin-cli getbalance. It differs in my case, and in the case of the other user (both testnet and mainnet for him, mainnet for me; I don't have any testnet coins right now).

  2. marcoagner commented at 10:42 AM on July 7, 2018: contributor

    I'm probably missing something but couldn't this be happening because getbalance doesn't count 0 confs by default (and in the case of mining on regtest, immature coins are not counted too) while listtransactions lists everything (0 conf, immature...)?

  3. marcoagner commented at 10:48 AM on July 7, 2018: contributor

    Here's what I'm doing so you can tell if I'm reproducing the issue or not:

    • run node1 on regtest
    • generate 101 blocks to myself
    • tests both commands and get 50 for getbalance and 5050 for the listtransactions sum (101 blocks * 50 reward)
    • run node2 on regtest
    • send between them and get different amounts from the same commands because of 0 confs and immature coins
  4. kallewoof commented at 5:02 AM on July 9, 2018: member

    @marcoagner No, there were no unconfirmed transactions.

  5. jonasschnelli commented at 8:27 AM on July 19, 2018: contributor

    If you have transactions with multiple outputs, wouldn't you count the fee twice?

  6. kallewoof commented at 8:58 AM on July 19, 2018: member

    @jonasschnelli Yes, that seems to be the problem. Thanks!

  7. kallewoof closed this on Jul 19, 2018

  8. DrahtBot 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-14 18:15 UTC

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