My application is using bitcoinj-0.11.3. I am using Wallet.getBalance(balanceType) to read wallet balance.

  • For AVAILABLE I get 8.94106037
    This is supposed to include all confirmed transactions.
  • For ESTIMATED I get 22.43822671.
    This mode assumes that all of the transactions in the memory pool are included into the blockchain.

Knowing my transactions this looks inaccurate as confirmed by blockr which indicates a balance of 24.48442767. Note that this doesn't include unconfirmed transactions.

So, there are two inaccuracies here:

  • 22.43822671 vs 24.48442767
  • AVAILABLE shows ~9 when it should show ~24.

While blockr balance seems right my funds keep in pending state. I suspect that wallet balance calculation is somehow wrong.

[Edit]: Might also help the output of Wallet.toString :

Wallet containing 22.43822671 BTC (available: 8.94106037 BTC) in: 5 pending transactions 79 unspent transactions 390 spent transactions 0 dead transactions

I think this also answers to Nick question that I am not scrambling numbers while converting the BigInteger.

  • I notice that getBalance returns a BigInteger. Are you converting this into a float at any point? That might be the cause of the minor innacuracy. – Nick ODell Nov 25 '14 at 6:43
  • People occasionally use testnet to test large block chain reorganizations (reorgs), sometimes creating forks of 2,000 blocks or more. Those reorgs break lots of software. It might be worth backing up your data directory and then telling BitcoinJ to rescan for transactions from its earliest key-creation date---if a reorg created the problem, that should fix it. (If that works, let me know and I'll turn this into an actual answer.) – David A. Harding Nov 25 '14 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.