<blockquote>
  <p>allowed by the protocol?</p>
</blockquote>

<p>Yes. It is possible to spend an output immediately. And two (three-four-etc) chaining transactions will be included in the same block. There are a lot of examples in blockchain. Note, that the their order in block is fixed. </p>

<blockquote>
  <p>do any of the common clients allow spending unconfirmed Bitcoins</p>
</blockquote>

<p>Bitcoin-core client allows to send "raw transaction" to spend unconfirmed bitcoins. Also the "change" output can be spent without confirmations. Holding incoming bitcoins for several confirmations is an interface option only, not a protocol rule.</p>

CC BY-SA 3.0
2014-09-12T15:22:43.273Z
2014-09-12T15:22:43.273Z
amaclin
<p>Sure. Miners simply receive both transactions and try to include them in a block.</p>

<p>Regarding confirmations, this is only a concern when wanting to claim a transaction you've received from someone else. If they're your own coins, there's no risk of a double spend.</p>

CC BY-SA 3.0
2014-09-12T15:50:39.023Z
There is risk of spending unconfirmed change because transactions are still malleable.
amaclin
CC BY-SA 3.0
2014-09-12T15:56:57.087Z
Can you elaborate more on this? Not sure I understand. Change is only calculated once the block's hash is found and therefore both transactions are included within it.
Luca Matteis
CC BY-SA 3.0
2014-09-12T17:55:42.007Z
OK, I will try to explain. I pay for a cup of coffee, sending tx1. One output 0.01 BTC for StarBucks and 0.01 change to myself. Right after that I spend my change for another cup of coffee for my girlfriend. Tx1 was malled by somebody and included in block with different hash. Tx2 becomes orphan and never be confirmed. Now StarBacks think that I (or my girlfriend?) am double-spender. Isn't is a risk for my reputation?
amaclin
CC BY-SA 3.0
2014-09-12T18:04:49.897Z
@amaclin your statement that transactions content are malleable requires a reference. It can be malled to change the transaction hash, but the miners won't think it's a different transaction because they check inputs/outputs.
Luca Matteis
CC BY-SA 3.0
2014-09-12T18:20:57.833Z
tx1 will still valid after [S := G-S] attack to ecdsa signature, but tx2 will not be confirmed, because its inputs refer to original hash of tx1. OK, it is not risk to lose your funds. It is a risk not to pay for something you want to pay. So, it does not matter - are you spending your own change, or funds incoming from anyone
amaclin
CC BY-SA 3.0
2014-09-12T15:32:08.580Z
2014-09-12T15:32:08.580Z
Luca Matteis
<p>Is a Bitcoin block containing both a transaction that funds an output, and another transaction that immediately spends the same output, allowed by the protocol?</p>

<p>Does such behavior occur "in the wild", e.g. do any of the common clients allow spending unconfirmed Bitcoins? Would miners include such transactions?</p>

CC BY-SA 3.0
2014-09-12T15:53:56.003Z
possible duplicate of [Can multiple transactions transferring the same bitcoin be done in one block?](http://bitcoin.stackexchange.com/q/1726/5406)
Murch
<transactions><protocol><output>
Can an output be spent in the block in which it is contained?
lxgr
# Can an output be spent in the block in which it is contained?

(Asked by: username_0 on 2014-09-12)

Is a Bitcoin block containing both a transaction that funds an output, and another transaction that immediately spends the same output, allowed by the protocol?

Does such behavior occur "in the wild", e.g. do any of the common clients allow spending unconfirmed Bitcoins? Would miners include such transactions?

**Tags:** transactions, protocol, output

> **Comments:**
> **username_1**: possible duplicate of [Can multiple transactions transferring the same bitcoin be done in one block?](http://bitcoin.stackexchange.com/q/1726/5406)  

---

## 2 answers

### Answer by username_2 on 2014-09-12. Score: 8

> allowed by the protocol?

Yes. It is possible to spend an output immediately. And two (three-four-etc) chaining transactions will be included in the same block. There are a lot of examples in blockchain. Note, that the their order in block is fixed.

> do any of the common clients allow spending unconfirmed Bitcoins

Bitcoin-core client allows to send "raw transaction" to spend unconfirmed bitcoins. Also the "change" output can be spent without confirmations. Holding incoming bitcoins for several confirmations is an interface option only, not a protocol rule.


---

### Answer by username_3 on 2014-09-12. Score: 1

Sure. Miners simply receive both transactions and try to include them in a block.

Regarding confirmations, this is only a concern when wanting to claim a transaction you've received from someone else. If they're your own coins, there's no risk of a double spend.

> **Comments:**
> **username_2**: There is risk of spending unconfirmed change because transactions are still malleable.  
> **username_3**: Can you elaborate more on this? Not sure I understand. Change is only calculated once the block's hash is found and therefore both transactions are included within it.  
> **username_2**: OK, I will try to explain. I pay for a cup of coffee, sending tx1. One output 0.01 BTC for StarBucks and 0.01 change to myself. Right after that I spend my change for another cup of coffee for my girlfriend. Tx1 was malled by somebody and included in block with different hash. Tx2 becomes orphan and never be confirmed. Now StarBacks think that I (or my girlfriend?) am double-spender. Isn't is a risk for my reputation?  
> **username_3**: @username_2 your statement that transactions content are malleable requires a reference. It can be malled to change the transaction hash, but the miners won't think it's a different transaction because they check inputs/outputs.  
> **username_2**: tx1 will still valid after [S := G-S] attack to ecdsa signature, but tx2 will not be confirmed, because its inputs refer to original hash of tx1. OK, it is not risk to lose your funds. It is a risk not to pay for something you want to pay. So, it does not matter - are you spending your own change, or funds incoming from anyone  

---

