1
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?
With all these invalidation of transactions, how do wallets even keep track of your available spending? – Larrrrrrrrrry – 2018-09-28T14:35:53.530
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 – 2018-09-28T14:37:24.280
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 – 2018-09-28T14:43:15.507
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 – 2018-09-28T14:51:28.047
1The 6 blocks deep is not a rule of Bitcoin, but decided by the wallet or user, so no. – JBaczuk – 2018-09-28T15:00:52.360
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 – 2018-09-28T23:06:10.947