sum(getaccounts) != getbalance #25

issue gavinandresen opened this issue on January 9, 2011
  1. gavinandresen commented at 11:43 PM on January 9, 2011: contributor

    tcatm has given me a -testnet wallet where sum(account) does not equal total server balance.

    That should be impossible. He did copy the wallet and use it on two different bitcoinds, but it should still be impossible for the accounts balances to get out of sync with the total wallet balance.

  2. mikegogulski commented at 2:49 AM on January 10, 2011: none

    Eek!

  3. gavinandresen commented at 2:56 AM on January 10, 2011: contributor

    Before I lose them: http://pastebin.com/evGiRVw2 and http://pastebin.com/wxCnw5SF ... are listaccounts and gettransactions '*' output. getbalance returns 850.05, sum(accounts) is 853.05... I'll be debugging this more tomorrow.

  4. mikegogulski commented at 3:07 AM on January 10, 2011: none

    txid 22c1af3bc7f21a1ee74fbe63fcc58d0433ce2c574cf042a8f9129f989ebac68d has two entries associated with it, one of which is for BTC 3, and this is the only BTC 3 transaction in what you pastebinned. Maybe a place to look.

  5. gavinandresen commented at 5:15 PM on January 10, 2011: contributor

    Thanks, mike, it looks like that is the source of the bug. There is 3BTC in "change" that is being miscounted, because the 'change' address was assigned to an account (using setaccount <change address> "", I assume).

    The good news is that unless you dig out change addresses from block explorer this bug won't affect you. It still needs fixing, though...

  6. tcatm commented at 5:49 PM on January 10, 2011: none

    I never used setaccount so something else must have caused it.

  7. gavinandresen commented at 2:00 PM on January 13, 2011: contributor

    After looking more at this, I'm puzzled. The 3BTC transaction is definitely weird, but I don't think that is the cause-- the accounts code thinks it is a multi-send-to-self, and it doesn't affect the account's total balance (it is +400 in, -400 out).

  8. mikegogulski commented at 2:13 PM on January 13, 2011: none

    Wishing I had the stones for c++ anymore... still, some thoughts:

    • maybe that tx isn't to blame.
    • does the bitcoin wallet implement a proper semblance of a double-entry ledger? If not, that's an enhancement request. (the pastebin records sure look like one, but i'm no accountant)
    • is there cause here to create an in-the-field assert which would trigger a client alert and prompt to submit tx data for fault analysis, in the event of such a disagreement?
  9. gavinandresen commented at 10:53 PM on January 13, 2011: contributor

    I asked Satoshi, and he has a very good theory and what happened:

    Wallet clone "A" spends some coins.

    Wallet clone "B" (this is the one I'm debugging) comes online, runs ReacceptWalletTransactions, sees the spend, and marks the previous transaction (where it got the coins) as spent. HOWEVER, it does NOT add the spend transaction to the wallet. That is the bug, it should.

  10. laanwj referenced this in commit d28ed9c98e on Sep 28, 2011
  11. coblee referenced this in commit e05433d00a on Jul 17, 2012
  12. kac- referenced this in commit a5c0f2711a on Jun 10, 2014
  13. rdponticelli referenced this in commit ebfa43b20a on Nov 26, 2014
  14. rubensayshi referenced this in commit 84046d503f on Mar 16, 2015
  15. dexX7 referenced this in commit 35229f0be8 on May 2, 2015
  16. sdaftuar referenced this in commit f29fe8a297 on May 14, 2015
  17. ptschip referenced this in commit dd95ea8c3a on Mar 11, 2016
  18. nining referenced this in commit 5e907e36ae on Jan 3, 2018
  19. KrzysiekJ referenced this in commit 7cd5894690 on Mar 28, 2018
  20. KolbyML referenced this in commit 5168cb2db2 on Aug 1, 2020
  21. KolbyML referenced this in commit 3a967773a9 on Sep 4, 2020
  22. rajarshimaitra referenced this in commit 4dc7b364d5 on Mar 23, 2021
  23. rajarshimaitra referenced this in commit 28082808d7 on Mar 23, 2021
  24. MarcoFalke referenced this in commit bce09da122 on Apr 28, 2021
  25. MarcoFalke referenced this in commit c857148636 on May 15, 2021
  26. satindergrewal referenced this in commit 34be553add on Jun 22, 2021
  27. rajarshimaitra referenced this in commit 776af4f3b6 on Aug 5, 2021
  28. MarcoFalke locked this on Sep 8, 2021
Labels
Linked (view graph)
#999 v0.6.0rc5 segfault on initial blockchain download when out of diskspace#1098 segfault in qrcode message dialog#5795 Bizarre test_bitcoin crash, but passes in debugger#9759 Setting -maxsigcachesize to zero causes segfault#9997 Running out of disk space during GUI init results in hang and non-drawing windows#10209 Stalled shutdown#11355 LevelDB read failure: Corruption: block checksum mismatch#12038 deadlock on database corruption#14349 mac: make check failure on macOS 10.14#14923 segmentation fault on gui startup#17540 ci build fails in ./qt/test/test_bitcoin-qt on aarch64 native tsan#17729 Fuzzing Bug undefined-behavior pubkey.cpp:210:38#18362 gui: segfault unloading and immediately reloading wallet with gui#20618 Data race in interface_zmq.py#21632 MemorySanitizer: use-of-uninitialized-value in sqlite3BtreeOpen#21773 fuzz: Ensure prevout is consensus-valid#21948 test: Fix off-by-one in mockscheduler test RPC#22548 CheckQueue_Correct_Random data race#24290 segfault when compiled with depends DEBUG=1 and libc++#25146 Starting with an unsupported wallet configured leads to a segfault (master only?)#25323 miniscript fuzzer failing after qa-assets update#25365 ThreadSanitizer: data race on vptr (ctor/dtor vs virtual call) in BaseIndex#25632 SUMMARY: ThreadSanitizer: SEGV src/index/base.cpp:388:9 in BaseIndex::SetBestBlockIndex(CBlockIndex const*)::$_1::operator()() const#25857 IBD core dumped during recursive call to CCoinsViewCache::FetchCoin (while connecting best chain tip)#26068 Segmentation fault in the scheduler thread when an index fails to commit to the db#26274 bitcoind dumps core when deriveaddresses is called with index 2147483647 (2^31-1)#27222 test: use-of-uninitialized-value in sqlite3Strlen30#27354 wallet: Data race in GetOrCreateLegacyScriptPubKeyMan vs IsMine#27360 ci: use LLVM/clang-16 in native_asan job#27582 TSAN: lock-order-inversion (potential deadlock) in ZapSelectTx test#27922 ci: fix llvm-symbolizer in MSAN jobs#28510 migratewallet crashes on an freshly created datadir ( wallet/wallet.h:959: int wallet::CWallet::GetLastBlockHeight() const: Assertion `m_last_block_processed_height >= 0' failed.)#28665 'std::out_of_range' crash in I2P fuzz test#29767 ThreadSanitizer: data race src/flatfile.cpp:47:13 in FlatFileSeq::Open(FlatFilePos const&, bool)#30402 Illegal Instruction in `CoinStatsIndex::CustomAppend`#31234 fuzz: connman target: terminate called after throwing an instance of 'std::bad_alloc'#32173 validation: `CheckBlockIndex` crashes during block reconsideration#33150 intermittent TSAN failure in lockmanager_tests::blockmanager_readblock_hash_mismatch#33277 intermittent Segmentation fault in mptest IPC path (callFnAsyncParams)#34655 fuzz: keep `coins_view` fuzzers within caller contracts#34734 test: Fix shutdown vptr race in BlockFilterIndexSync bench#34777 ipc: AddressSanitizer: heap-use-after-free in `capnp::CallContext<ipc::capnp::messages::BlockTemplate::GetBlockParams, ipc::capnp::messages::BlockTemplate::GetBlockResults>::getParams()`#34782 mptest: mp::CancelMonitor: AddressSanitizer: stack-use-after-return

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