Difference in getbalance and sum(listtransactions) amounts (testnet) #7054

issue asfin opened this issue on November 18, 2015
  1. asfin commented at 2:29 PM on November 18, 2015: none

    I have bunch of wallets which i import in fresh and empty bitcoind via importwallet. After this i issue getbalance, which shows me 0.00000000, but if i perform listtransactions and sum all amounts and fees(single fee per tx) i've got 0.00004137. Why?

    Bitcoin Core Daemon version v0.11.1.0-gcf33f19
    

    check_tx.py.txt listtransactions.json.txt unspent.json.txt

  2. jonasschnelli added the label Wallet on Nov 18, 2015
  3. jonasschnelli commented at 8:00 PM on November 18, 2015: contributor

    I shortly checked your receiving addresses over an testnet API, seems to be 0 balance. Could be a mistake in your script (fees correctly handled?!) or a missing transaction in your listtransaction.txt

  4. asfin commented at 8:56 PM on November 18, 2015: none

    I've checked again, listtransactions.txt is fine. Script also should be ok, but i'll be glad if someone more experienced check it.

  5. laanwj commented at 2:56 PM on November 19, 2015: member

    Some transactions have negative "fee", that's weird.

  6. asfin commented at 6:08 PM on November 19, 2015: none

    I'm think it happens because this addresses are part of larger wallet, and positive fees are "change", am i right?

  7. MarcoFalke commented at 6:36 PM on November 19, 2015: member

    No, change is already considered in the "amount" value. @asfin I guess you forgot to import some keys of some of the transactions. (Maybe coinjoin?) Could you try again and assert that you have all addresses in you wallet?

  8. sipa commented at 6:46 PM on November 19, 2015: member

    Fee is computed as (sum of outputs)-(sum of inputs that are ours)... that is meaningless if not all inputs are ours.

  9. MarcoFalke commented at 7:32 PM on November 19, 2015: member

    @sipa Yes, and it's in there since at least 2011™

  10. asfin commented at 8:54 PM on November 19, 2015: none

    @MarcoFalke OK, I'll try to import complete wallet and attach result. But i've found this problem on it, and after this tried to split wallet on small parts, to isolate error. It seems to be weird, if after importing privkey my balance doesn't match transaction history.

  11. MarcoFalke commented at 10:24 PM on November 19, 2015: member

    @asfin Yes, if you don't import all private key related to all transactions, you will get a difference when summing up the values reported by listtransactions in current versions of bitcoin.

  12. asfin commented at 9:47 AM on November 20, 2015: none

    Replaced wallet.dat with backup of original, and performed reindex. Script reports:

    unspent     :   12.33503283
    total income:   12.34391710
    total fee   :   -0.00884290
    diff        :   12.33507420
    

    but in attached version of script, diff doesn't include unspent balance so diff-unspent=error; 12.33507420-12.33503283=0.00004137. How correctly find tx, which broke this?

    listtransactions.json.txt unspent.json.txt

  13. MarcoFalke commented at 12:14 PM on November 20, 2015: member

    How correctly find tx, which broke this?

    Should be at least all those with negative fee

  14. asfin commented at 1:22 PM on November 20, 2015: none

    But here all fees < 0.

  15. MarcoFalke commented at 1:32 PM on November 20, 2015: member

    Yes, listtransactions always should return a negative fee. (Internally they are handled positive: nFee in https://github.com/bitcoin/bitcoin/blob/776848acefa8345c7e510d31406160c4a1a24bca/src/wallet/wallet.cpp#L969)

  16. MarcoFalke commented at 5:55 PM on September 28, 2016: member

    Not clear this is an issue

  17. MarcoFalke closed this on Sep 28, 2016

  18. snakehopper commented at 6:25 AM on January 17, 2019: none

    I am facing same issue after importwallet. It show wallet got 302 txs, but listtransactions only return 285 txs

    bitcoin-cli -version

    Bitcoin Core RPC client version v0.16.3

    bitcoin-cli listtransactions "*" 999999 | grep txid | wc

    285 570 22800

    bitcoin-cli getwalletinfo

    { "walletname": "wallet.dat", "walletversion": 159900, "balance": 0.02000434, "unconfirmed_balance": 0.00000000, "immature_balance": 0.00000000, "txcount": 302, ... }

    bitcoin-cli getbalance

    0.02000434

    bitcoin-cli listunspent | grep amount

    "amount": 0.01000216, "amount": 0.01000218,

  19. snakehopper commented at 11:28 AM on January 18, 2019: none

    I get it. It is not importwallet problem. The real issue is listtransactions does not return amount=0 transactions, for example sendtoaddress to a internal addresses within the wallet , even the transaction fee is non zero.

  20. DrahtBot locked this on Dec 16, 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-21 15:15 UTC

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