Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Hal on January 28, 2011, 09:41:15 PM



Title: What if you spend after receiving a double spend?
Post by: Hal on January 28, 2011, 09:41:15 PM
Suppose you receive a payment and then immediately spend it. Then there is a block reorganization and the payment to you goes away. It never comes back because it was a double spend. Can the client handle this? How would it appear in the transaction window?


Title: Re: What if you spend after receiving a double spend?
Post by: caveden on January 29, 2011, 11:58:54 AM
What's interesting is to ask what happens if in the inputs you have addresses that are "fine" and others which have their balance dependent on the double-spend. What happens to this transactions after the block reorganization?


Title: Re: What if you spend after receiving a double spend?
Post by: Mike Hearn on January 29, 2011, 12:30:22 PM
I think the transactions in question will go back to showing as zero confirmations.


Title: Re: What if you spend after receiving a double spend?
Post by: Cdecker on January 30, 2011, 11:41:27 AM
I think the transactions in question will go back to showing as zero confirmations.
Exactly, it'll return to 0 and never confirm :D
Btw: all transactions could be invalidated, it's just incredibly unlikely, because someone would have to fork the chain before the transaction and overtake the current chain.


Title: Re: What if you spend after receiving a double spend?
Post by: theymos on January 30, 2011, 12:15:18 PM
What's interesting is to ask what happens if in the inputs you have addresses that are "fine" and others which have their balance dependent on the double-spend.

The good inputs will end up getting stuck. There was an "outbreak" of a similar issue a while ago when Bitcoin sent 0-confirmation coins that would never confirm, permanently tying up all of the other coins in that transaction. Bitcoin now never sends 0-confirmation coins and prefers to send fully-confirmed coins, so this sort of thing should be less likely.

ReacceptWalletTransactions() already re-checks your transactions on Bitcoin startup, but it doesn't seem to remove the transactions if they've become invalid. Maybe it should do so for sent transactions.