Let's say you have 0.025 BTC.
You give it to someone, and they send you 0.026 BTC.
They double spend it, and you have around 0.5 left in your wallet.
If you send the 0.5 while the other transaction is unconfirmed, what happens to the 0.5?
Just something I've always wondered about
I doubt the 0.5 would even be a valid transaction, because it requires conflicting inputs. In any way, as soon as once of the competing TX confirms the 0.5 TX is invalid because one of its inputs became invalid.
So would you eventually get the 0.5 BTC back and lose the 0.026?
Or would you end up with nothing left in your wallet.
Thanks.
I probably misunderstood where the 0.5 btc came from on my first answer, let me try again.
It depends. Lets say you have a single input of 0.75 BTC and alice has a single input of 0.26
You send 0.25 to alice (the (u) marks unconfirmed coins)
you alice
0.5(u) 0.26
0.25(u)
Alice now sends you 0.26.
you alice
0.26(u) 0.25(u)
0.5(u)
and the same input to bob (the (c) marks conflicting transactions)
you alice bob
0.26(u,c) 0.25(u) 0.26(u,c)
0.5(u)
Now, if the first TX confirms, we have this.
you alice bob
0.26(u,c) 0.25 0.26(u,c)
0.5
If the double spend to bob confirms, your 0.26 from alice are invalid and will disappear (or still show as conflicted/pending depending on your wallet).
you alice bob
0.5 0.25 0.26
If the TX from alice to you confirms, bobs 0.26 from alice are invalid and will disappear.
you alice bob
0.26 0.25 -
0.5
So the 0.5 change is unaffected by alice's double spend. This is also true if the 0.5 was a different input and not created by the TX sending 0.25 to alice.