3

Let's assume I create and send a series of txs:

|------block A--------|------block B----------|----block C-----|----block D-----|
|Tx1......Tx2.........|...Tx3.................|................|......Tx4.......|

but then a fork happens and a block reorganization takes place:

|------block A--------|------block B----------|----block E-----|----block F-----|--block G--|
|Tx1......Tx2.........|...Tx3.................|......???.......|......???.......|.....???...|

Whatever happens to Tx4? Will it be included in one of blocks E, F, G or another block? Is it gone? Conflicted/invalidated? Do I need to resend it? If yes, can I spend the same inputs I did when creating Tx4?

1 Answer 1

5

Will it be included in one of blocks E, F, G or another block?

It's likely already included in one of those blocks. If not, it can be included in a block after that.

Do I need to resend it?

Probably not. If block D or Tx4 was widely seen by the network, it should get into a block soon. (It might already be in blocks E, F, or G.)

If yes, can I spend the same inputs I did when creating Tx4?

Yes. When doing a reorg, the Bitcoin client first rolls the chainstate back to the first common ancestor.

The standard Bitcoin client actually includes a database for the sole purpose of rolling the blockchain back. (It's called an undofile.)

5
  • Thanks Nick! How is it determined which block (E/F/G/other) Tx4 is likely to be included into? If Tx4 is not included in any of the "new" blocks, what is the number of blocks after that point at which we can safely assume that Tx4 will not be included in any of the future blocks? Jan 8, 2015 at 17:17
  • 1
    @DougPeters How is it determined which block (E/F/G/other) Tx4 is likely to be included into? It's decided by the miner before they mine those blocks. Miners will include most transactions, provided that they are legal, pay fees, and the miner knows about them.
    – Nick ODell
    Jan 8, 2015 at 17:21
  • 1
    @DougPeters what is the number of blocks after that point at which we can safely assume that Tx4 will not be included Never. You could wait 10 years, put Tx4 into a block, and it would still be legal. However, if it's been 4 days, the transaction has probably been forgotten.
    – Nick ODell
    Jan 8, 2015 at 17:22
  • 4 days is an arbitary number I assume? Jan 8, 2015 at 17:28
  • 1
    @DougPeters Pretty much. This answer explains it better than I can.
    – Nick ODell
    Jan 8, 2015 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.