<p>If transaction Y is in block B, then it is - for purposes of deciding whether X's inputs are valid - confirmed.</p>

<p>As far as consensus rules are concerned, a transaction X can spend outputs from a transaction Y that is anywhere in the block chain before X. That means either Y is in an earlier block as X, or in the same block but in an earlier position.</p>

<p>The P2P transaction relay also supports this. It will relay transactions that spend outputs of unconfirmed transactions under some conditions. Given two interdependent unconfirmed transactions, miners can decide to put both of them in the same block, or only include the first one in a block (leaving the other one in the memory pool for inclusion in a later block).</p>

CC BY-SA 3.0
2017-01-06T04:06:34.863Z
2017-01-06T04:06:34.863Z
Pieter Wuille
<p>The inputs of a transaction reference outputs of previous transactions. These previous transactions</p>

<ul>
<li>must already be present in the block chain, or</li>
<li>can also be pending transactions?</li>
</ul>

<p>I don't know if the term <em>pending transactions</em> has some meaning I'm not aware of. In this context, I mean transactions that are not yet in the block chain, but are present in the block containing the new transaction.</p>

<p><strong>Example</strong>: A particular block <code>B</code> contains multiple transactions including a transaction <code>X</code> and a transaction <code>Y</code>. The transaction <code>X</code> references the output(s) of transaction <code>Y</code>. Transaction <code>Y</code> is not yet in the block chain, but <em>it is</em> present in block <code>B</code> as well. Is this possible since transaction <code>Y</code> is not yet confirmed?</p>

<p><strong>Note</strong>: I'm not using the term <em>unconfirmed transaction</em> because as I understand these are transactions not appearing in any block; and in this case transaction <code>Y</code> would be in a block, the same block as transaction <code>X</code>.</p>

<transactions><blockchain><unconfirmed-transactions>
Can transaction inputs reference outputs of pending transactions?
Daniel
# Can transaction inputs reference outputs of pending transactions?

(Asked by: username_0 on 2017-01-05)

The inputs of a transaction reference outputs of previous transactions. These previous transactions

* must already be present in the block chain, or
* can also be pending transactions?

I don't know if the term *pending transactions* has some meaning I'm not aware of. In this context, I mean transactions that are not yet in the block chain, but are present in the block containing the new transaction.

**Example**: A particular block `B` contains multiple transactions including a transaction `X` and a transaction `Y`. The transaction `X` references the output(s) of transaction `Y`. Transaction `Y` is not yet in the block chain, but *it is* present in block `B` as well. Is this possible since transaction `Y` is not yet confirmed?

**Note**: I'm not using the term *unconfirmed transaction* because as I understand these are transactions not appearing in any block; and in this case transaction `Y` would be in a block, the same block as transaction `X`.

**Tags:** transactions, blockchain, unconfirmed-transactions


---

## 1 answers

### Answer by username_1 on 2017-01-06. Score: 4 | Accepted answer

If transaction Y is in block B, then it is - for purposes of deciding whether X's inputs are valid - confirmed.

As far as consensus rules are concerned, a transaction X can spend outputs from a transaction Y that is anywhere in the block chain before X. That means either Y is in an earlier block as X, or in the same block but in an earlier position.

The P2P transaction relay also supports this. It will relay transactions that spend outputs of unconfirmed transactions under some conditions. Given two interdependent unconfirmed transactions, miners can decide to put both of them in the same block, or only include the first one in a block (leaving the other one in the memory pool for inclusion in a later block).


---

