<blockquote>
  <p>What if TX_A gets orphaned due to forks? What happens to TX_B?</p>
</blockquote>

<p>It will be considered invalid, and your Bitcoin will not be spent. It will only be considered valid on the other forks, assuming they don't also invalidate the block. Usually the forks, if they are trying to play by the rules of the Bitcoin network, will also invalidate the block because the longest chain is always the valid chain.</p>

<p>Also, this should be referred to as an <em>extinct</em> block, see <a href="https://bitcoin.stackexchange.com/a/5869/60443">https://bitcoin.stackexchange.com/a/5869/60443</a></p>

CC BY-SA 4.0
2018-09-28T14:35:53.530Z
With all these invalidation of transactions, how do wallets even keep track of your available spending?
Larrrrrrrrrry
CC BY-SA 4.0
2018-09-28T14:37:24.280Z
First, extinct blocks are not terribly common, though they have and will happen. However, wallets need to account for the possibility of orphaned blocks, if they don't they are putting their users at risk. Also, they typically require a minimum number of confirmations for new transactions before they allow spending.
JBaczuk
CC BY-SA 4.0
2018-09-28T14:43:15.507Z
correction, this terminology is confusing, and should be referred to as extinct blocks. orphans are just blocks with an unknown parent, but not necessarily invalid.
JBaczuk
CC BY-SA 4.0
2018-09-28T14:51:28.047Z
Thanks for the clarification. From what I read about confirmations, outputs can only be spent if the transaction that outputted them are 6 blocks deep in the blockchain. Does this mean that a block is invalid if a transaction's input cannot be matched with any outputs that are 6 blocks away (in the direction of the genesis block)?
Larrrrrrrrrry
CC BY-SA 4.0
2018-09-28T15:00:52.360Z
The 6 blocks deep is not a rule of Bitcoin, but decided by the wallet or user, so no.
JBaczuk
CC BY-SA 4.0
2018-09-28T23:06:10.947Z
Note that most of the time, competing blocks at the same height will include a largely overlapping set of transactions as almost every miner selects their transactions by picking the transactions with the highest fee rate from their mempool. -- Thus, if there are no shenanigans such as doublespend attempts, your transaction should get included in the other chaintip at the same height or briefly later.
Murch
CC BY-SA 4.0
2018-09-28T14:32:56.037Z
2018-09-28T23:05:11.510Z
2018-09-28T23:05:11.510Z
JBaczuk
<p>The way I understand your question, you are asking:</p>
<blockquote>
<p>Assuming I get paid by a transaction <code>tx_a</code> that gets included in a block. I spend my output in another transaction <code>tx_b</code>. What happens to <code>tx_b</code> if <code>tx_a</code> gets unconfirmed in a reorganization?</p>
</blockquote>
<p>When the node reorganizes to another chaintip, all transactions that were confirmed in the block that confirmed <code>tx_a</code> get added back to the mempool. Some of these transactions may already also be confirmed in the chaintip that the node is reorganizing to, but otherwise both <code>tx_a</code> and <code>tx_b</code> are now in the mempool. It is permitted to spend outputs of unconfirmed transactions, so that is not an issue at all, unless another transaction spent some of the inputs of <code>tx_a</code> in a <em>doublespend</em> that made <code>tx_a</code> permanently invalid. In that case, <code>tx_b</code> would of course also be discarded, since <code>tx_a</code> could never be part of the best chain given that some of its inputs were already spent.</p>

CC BY-SA 4.0
2023-10-20T14:55:30.340Z
2023-10-20T14:55:30.340Z
Murch
<p>This is a theoretical question. Assuming that a transaction (TX_A) with me on the receiving end gets added to the blockchain, I should be able to spend the amount I received. So I go on and spend it on another transaction (TX_B). What if TX_A gets orphaned due to forks? What happens to TX_B?</p>

<blockchain><blockchain-fork><chain-reorganization>
Transaction in orphaned block question
Larrrrrrrrrry
# Transaction in orphaned block question

(Asked by: username_0 on 2018-09-28)

This is a theoretical question. Assuming that a transaction (TX\_A) with me on the receiving end gets added to the blockchain, I should be able to spend the amount I received. So I go on and spend it on another transaction (TX\_B). What if TX\_A gets orphaned due to forks? What happens to TX\_B?

**Tags:** blockchain, blockchain-fork, chain-reorganization


---

## 2 answers

### Answer by username_1 on 2018-09-28. Score: 1

> What if TX\_A gets orphaned due to forks? What happens to TX\_B?

It will be considered invalid, and your Bitcoin will not be spent. It will only be considered valid on the other forks, assuming they don't also invalidate the block. Usually the forks, if they are trying to play by the rules of the Bitcoin network, will also invalidate the block because the longest chain is always the valid chain.

Also, this should be referred to as an *extinct* block, see <https://bitcoin.stackexchange.com/a/5869/60443>

> **Comments:**
> **username_0**: With all these invalidation of transactions, how do wallets even keep track of your available spending?  
> **username_1**: First, extinct blocks are not terribly common, though they have and will happen. However, wallets need to account for the possibility of orphaned blocks, if they don't they are putting their users at risk. Also, they typically require a minimum number of confirmations for new transactions before they allow spending.  
> **username_1**: correction, this terminology is confusing, and should be referred to as extinct blocks. orphans are just blocks with an unknown parent, but not necessarily invalid.  
> **username_0**: Thanks for the clarification. From what I read about confirmations, outputs can only be spent if the transaction that outputted them are 6 blocks deep in the blockchain. Does this mean that a block is invalid if a transaction's input cannot be matched with any outputs that are 6 blocks away (in the direction of the genesis block)?  
> **username_1**: The 6 blocks deep is not a rule of Bitcoin, but decided by the wallet or user, so no.  
> **username_2**: Note that most of the time, competing blocks at the same height will include a largely overlapping set of transactions as almost every miner selects their transactions by picking the transactions with the highest fee rate from their mempool. -- Thus, if there are no shenanigans such as doublespend attempts, your transaction should get included in the other chaintip at the same height or briefly later.  

---

### Answer by username_2 on 2023-10-20. Score: 0

The way I understand your question, you are asking:

> Assuming I get paid by a transaction `tx_a` that gets included in a block. I spend my output in another transaction `tx_b`. What happens to `tx_b` if `tx_a` gets unconfirmed in a reorganization?

When the node reorganizes to another chaintip, all transactions that were confirmed in the block that confirmed `tx_a` get added back to the mempool. Some of these transactions may already also be confirmed in the chaintip that the node is reorganizing to, but otherwise both `tx_a` and `tx_b` are now in the mempool. It is permitted to spend outputs of unconfirmed transactions, so that is not an issue at all, unless another transaction spent some of the inputs of `tx_a` in a *doublespend* that made `tx_a` permanently invalid. In that case, `tx_b` would of course also be discarded, since `tx_a` could never be part of the best chain given that some of its inputs were already spent.


---

