saifi009 / bitcoinj

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

Non-fatal NullPointerException and lost coins when receiving bitcoins #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Have a look at
http://blockexplorer.com/testnet/address/mkpfXCwR7m4NGZu6oLubYrTW4g71uUx3jv

I was sending 5 BTC 
(9d12d10f0b29239e0807744daa50b22b4079657b12a4a0fdb842abe70f6d1ec0) from the 
Satoshi client while the BitCoinJ client was NOT active. After I saw that the 
tx was included in a block, I started the BitCoinJ client. Soon after, I 
received the transaction and the following exception occured. The 5 BTC are not 
visible in Wallet.getBalance(ESTIMATED) right now, although they should.

Note that I have the patch from issue 35 applied.

W/System.err(25136): 584416 [main] INFO com.google.bitcoin.core.Peer - 
blockChainDownload(0000000000000000000000000000000000000000000000000000000000000
000)
W/System.err(25136): 584822 [Bitcoin peer thread: [46.4.245.112]:18333 
(connected)] INFO com.google.bitcoin.core.BlockChain - 1 blocks per second
W/System.err(25136): 584834 [Bitcoin peer thread: [46.4.245.112]:18333 
(connected)] INFO com.google.bitcoin.core.Wallet - Received tx for 5.00 BTC: 
9d12d10f0b29239e0807744daa50b22b4079657b12a4a0fdb842abe70f6d1ec0
W/System.err(25136): java.lang.NullPointerException
W/System.err(25136):    at 
com.google.bitcoin.core.Wallet.updateForSpends(Wallet.java:341)
W/System.err(25136):    at 
com.google.bitcoin.core.Wallet.processTxFromBestChain(Wallet.java:307)
W/System.err(25136):    at com.google.bitcoin.core.Wallet.receive(Wallet.java:282)
W/System.err(25136):    at com.google.bitcoin.core.Wallet.receive(Wallet.java:211)
W/System.err(25136):    at 
com.google.bitcoin.core.BlockChain.scanTransaction(BlockChain.java:409)
W/System.err(25136):    at 
com.google.bitcoin.core.BlockChain.sendTransactionsToWallet(BlockChain.java:276)
W/System.err(25136):    at 
com.google.bitcoin.core.BlockChain.connectBlock(BlockChain.java:173)
W/System.err(25136):    at 
com.google.bitcoin.core.BlockChain.add(BlockChain.java:156)
W/System.err(25136):    at 
com.google.bitcoin.core.BlockChain.add(BlockChain.java:102)
W/System.err(25136):    at 
com.google.bitcoin.core.Peer.processBlock(Peer.java:129)
W/System.err(25136):    at com.google.bitcoin.core.Peer.run(Peer.java:87)
W/System.err(25136):    at com.google.bitcoin.core.Peer.access$1(Peer.java:79)
W/System.err(25136):    at com.google.bitcoin.core.Peer$1.run(Peer.java:66)
W/System.err(25136):    at java.lang.Thread.run(Thread.java:1019)

Original issue reported on code.google.com by andreas....@gmail.com on 2 Jul 2011 at 9:33

GoogleCodeExporter commented 9 years ago
Interesting. That line runs when there's a double spend detected:

Transaction connected = 
doubleSpent.outputs.get((int)input.outpoint.index).getSpentBy().parentTransactio
n;

Unfortunately it's quite a complicated expression (too complicated), so it's 
hard to know which part was null.

But presumably you weren't intending to double spend :-) What was the exact 
sequence of events that led to this? Presumably the wallet is unavailable this 
time too?

Original comment by hearn@google.com on 2 Jul 2011 at 9:39

GoogleCodeExporter commented 9 years ago
I promised the wallet will not be unavailable again, so here it is (-:

I did not intend to double-spend.

I tried to describe the series of events in my bug report. All tx before 
(received 4 btc, sent 1.5 btc, sent 2.5 btc) went well, the client reported a 
balance of 0 btc after sending away the 2.5 btc (at the entry point of this bug 
report).

Original comment by andreas....@gmail.com on 2 Jul 2011 at 9:52

Attachments:

GoogleCodeExporter commented 9 years ago
Ah, and I think you can see from the linked blockexplorer dump that tx 
9d12d10f0b29239e0807744daa50b22b4079657b12a4a0fdb842abe70f6d1ec0 was indeed no 
double-spend.

Original comment by andreas....@gmail.com on 2 Jul 2011 at 9:54

GoogleCodeExporter commented 9 years ago
What you see here is a false double-spend as documented in issue #64. 

Original comment by jan.mol...@gmail.com on 26 Jul 2011 at 8:57

GoogleCodeExporter commented 9 years ago

Original comment by hearn@google.com on 5 Aug 2011 at 9:21