Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: ManaUser on November 07, 2013, 11:16:44 AM



Title: Could coins from an unconfirmed transaction accidently be paid as fees? [Nope]
Post by: ManaUser on November 07, 2013, 11:16:44 AM
I recently had some bitcoins stuck in unconfirmed limbo for a while, it's taken care of, but it got me thinking... could the following happen?

1AAA is a bitcoin address. It contains 10 BTC.
I attempt to send all of it to 1BBB, but for whatever reason, this doesn't make it into the blockchain.
Presumably I'd notice that, but maybe I'm in a hurry and plan to deal with it later.
In the mean time: 1CCC sends another 1 BTC to 1AAA.
And I try to send half of that on to 1DDD.
My client believes 1AAA only contains 1 BTC so...
It would go something like txin=1AAA txout=1DDD:0.5 txout=1EEE:0.5 (the latter being my change)
But the rest of the network thinks 1AAA has 11 BTC in it so...
"Hey they didn't mention these 10 BTC, it must our fee, yay!"

Would Bitcoin-qt actually do this? If not, what steps does it take to avoid this situation?


Title: Re: Could coins from an unconfirmed transaction accidently be paid as fees?
Post by: domob on November 07, 2013, 11:53:27 AM
No, this is not possible (if I understand your concern correctly).  The point is that transaction inputs are never addresses but unspent outputs.  In your case, let's assume that the initial 10 BTC are form a single transaction, then the 1AAA address contains this one output.  If you now receive 1 BTC to 1AAA in addition, you have now two outputs that can be spent with the private key of 1AAA, but they only will be spent if the client explicitly includes both outputs (or one of them, then only the coins of that one will be spent).

If now one transaction with the 10 BTC is stuck, the client only thinks the other unspent output with 1 BTC is available; and if it creates a new transaction, it spends this output, but this has nothing to do with the other 10 BTC.  So it can never accidentally spend more than it thinks it spends, because it has to be completely aware of all outputs that you try to spend when you create a new transaction.


Title: Re: Could coins from an unconfirmed transaction accidently be paid as fees?
Post by: ManaUser on November 07, 2013, 03:36:17 PM
I see. Yes I think that was the distinction I was missing.