novitski / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
Apache License 2.0
0 stars 0 forks source link

failed preconditions and bad wallet balance #366

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On latest master, I get several failed preconditions. And my wallet balance is 
different after each blockchain replay (and never right).

Examples (full log attached):

W/System.err(24640): java.lang.IllegalStateException
W/System.err(24640):    at 
com.google.common.base.Preconditions.checkState(Preconditions.java:133)
W/System.err(24640):    at 
com.google.bitcoin.core.Wallet.receive(Wallet.java:1158)
W/System.err(24640):    at 
com.google.bitcoin.core.Wallet.receiveFromBlock(Wallet.java:1027)

---

W/System.err(24640): java.lang.IllegalStateException
W/System.err(24640):    at 
com.google.common.base.Preconditions.checkState(Preconditions.java:133)
W/System.err(24640):    at 
com.google.bitcoin.core.Wallet.addWalletTransaction(Wallet.java:1536)
W/System.err(24640):    at 
com.google.bitcoin.core.Wallet.receive(Wallet.java:1108)
W/System.err(24640):    at 
com.google.bitcoin.core.Wallet.receiveFromBlock(Wallet.java:1027)

Original issue reported on code.google.com by andreas....@gmail.com on 24 Mar 2013 at 7:20

Attachments:

GoogleCodeExporter commented 9 years ago
Just reset my wallet. First tx that arrived:

W/System.err( 5561): 1011191 [Wallet auto save thread] INFO 
com.google.bitcoin.core.Wallet - Auto-saving wallet, last seen block is 
00000000000004876c219002c6a1b273326c72e283dfb8f227ee32d3e2c60d6c
W/System.err( 5561): 1011520 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.AbstractBlockChain - 5 blocks per second
W/System.err( 5561): 1011779 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet - Received tx  for 0.02 BTC: 
a4c8af079ea4cc2e474ffcdae9310daa53edee27ac3201c3f6662ed2d4748fec
W/System.err( 5561): 1011780 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet -   new tx 
a4c8af079ea4cc2e474ffcdae9310daa53edee27ac3201c3f6662ed2d4748fec ->unspent
W/System.err( 5561): 1011781 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet - Balance is now: 0.00
W/System.err( 5561): 1012532 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.AbstractBlockChain - 30 blocks per second
W/System.err( 5561): 1012552 [Wallet auto save thread] INFO 
com.google.bitcoin.core.Wallet - Auto-saving wallet, last seen block is 
00000000000003a51e74a84c542f662c4fc5054d3762491a75772250af73c7e5

How can it be possible that after receiving 0.02 BTC the balance is 0.00 BTC?

This is with Bitcoin Wallet 2.46 (bitcoinj 0.7.3).

Will be attaching the full log as soon as its available.

Original comment by andreas....@gmail.com on 25 Mar 2013 at 10:52

GoogleCodeExporter commented 9 years ago
Another strange example:

W/System.err( 5561): 2429460 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet - Received tx  for 7.13166144 BTC: 
69df507c7312cdcb8f70937673ad3dcd5a5c4cb8513ec3bf439e9ea97609f85b
W/System.err( 5561): 2429461 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet -   new tx 
69df507c7312cdcb8f70937673ad3dcd5a5c4cb8513ec3bf439e9ea97609f85b ->unspent
W/System.err( 5561): 2429462 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet - Balance is now: 1.17437684
W/System.err( 5561): 2429556 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet - Received tx  for -5.0005 BTC: 
9b1cec8fa771d3c1a8bb4da643259d1a480c92215edb67f2c061667786d87575
W/System.err( 5561): 2429557 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet -   
69df507c7312cdcb8f70937673ad3dcd5a5c4cb8513ec3bf439e9ea97609f85b prevtx 
<-unspent
W/System.err( 5561): 2429558 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet -   
69df507c7312cdcb8f70937673ad3dcd5a5c4cb8513ec3bf439e9ea97609f85b prevtx ->spent
W/System.err( 5561): 2429559 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet -   new tx 
9b1cec8fa771d3c1a8bb4da643259d1a480c92215edb67f2c061667786d87575 ->unspent
W/System.err( 5561): 2429561 [New I/O client worker #2-1] INFO 
com.google.bitcoin.core.Wallet - Balance is now: 1.17437684

(two times the same balance)

Original comment by andreas....@gmail.com on 25 Mar 2013 at 11:14

GoogleCodeExporter commented 9 years ago
This is the complete log.

Original comment by andreas....@gmail.com on 26 Mar 2013 at 12:00

Attachments:

GoogleCodeExporter commented 9 years ago
It's rather confusing to have reports from different versions of the code all 
mixed together. Anyway, this sort of thing can happen if you accidentally 
replay a chain into a wallet without clearing it properly. Is it possible that 
this may have happened? Because I never saw things like this in my own testing, 
but if you replay a chain on top of an already full wallet, pretty much any 
kind of corruption can occur.

Original comment by hearn@google.com on 27 Mar 2013 at 10:53

GoogleCodeExporter commented 9 years ago
After conversation with Mike I am convinced that the root issue was caused by 
not clearing the wallet completely on a blockchain replay (a race in my code). 
However, the symptoms were amplified by other issues, like not displaying the 
balance in the logfile correctly. I have opened individual tickets for those.

Since this root issue has not surfaced any more after fixing my code, I'll 
close this issue.

Original comment by andreas....@gmail.com on 29 Mar 2013 at 2:30