Can transaction inputs reference outputs of pending transactions? 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.
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).