Bitcoin: can transaction and its parent be in the same block

0

I'm trying to understand bitcoin transactions verification specified here. Item 10 states, that parent transaction (mentioned as input for current) should be searched not only in already confirmed transactions (in main chain), but also in transaction pool (which contains unconfirmed transactions). This means, that transaction can become a candidate to be added to block even if it's parent is not in the blockchain. If this is true, than consider following situation:

  1. Transactions A and B are created in the same moment, A is parent of B.
  2. Miner receives both of them, both are considered valid.
  3. Miner adds only transaction B to block.

If such block is mined, it will be invalid, because other nodes will fail to validate transaction B. But if we also insert transaction A in it, will validation succeed on other nodes? I.e., is it possible to add transaction and its parent to the same block?

Anton Pantuykhin

Posted 2018-08-20T12:20:09.877

Reputation: 3

Question was closed 2018-08-23T14:29:57.353

Yes, you're right. I performed search using different search strings and did not see this post, thank you.Anton Pantuykhin 2018-08-21T09:46:08.933

Answers

1

is it possible to add transaction and its parent to the same block?

Yes, as long as A exists in the mempool when B is submitted, it will be allowed in the mempool, and can be in the same block, see Order of transactions within a block. A transaction that consumes invalid unspent outputs (UTXOs) will be rejected before it enters the mempool.

If a miner mines a block with a transaction (in this case B) that has an invalid input (ie the UTXO it is spending does not exist), the block will be rejected when it is submitted because it is a block with invalid transactions.

JBaczuk

Posted 2018-08-20T12:20:09.877

Reputation: 6 172

1

I.e., is it possible to add transaction and its parent to the same block?

Yes. The "parent" transaction must be earlier in block.

amaclin

Posted 2018-08-20T12:20:09.877

Reputation: 5 763