Do stale blocks get reported by bitcoin daemon?

1

1

Do stale blocks end up or get reported by bitcoin daemon client? I am writing a bitcoin service and need to listen for incoming transactions for select accounts using the bitcoin client. For this I am watching the blocks as they come into the blockchain. And for periods of time the service is down, we keep track of the last block height and once the service is back online, restart traversing the blockchain from there until we catch up with the tip.

My questions are:

  1. Does the client report stale blocks which are mined into the blockchain but not part of the main chain or are they ignored and hidden from me?

  2. Also if the stale blocks are being reported, what would I need to to with the transactions from that block?

  3. How do I detect if a block is stale?

androidu

Posted 2018-04-13T14:05:30.767

Reputation: 111

Answers

1

My question is: does the client report stale blocks which are mined into the blockchain but not part of the main chain or are they ignored and hidden from me?

Blocks that are not part of the main chain are never reported unless you specifically ask for them.

However if you are online, new blocks can become stale blocks and you will need to be able to handle that case.

what would I need to to with the transactions from that block?

Undo everything that happened in that block. So all of the transactions become unconfirmed and go back to the mempool. Any UTXOs that were spent become unspent and re-enter the UTXO set.

Andrew Chow

Posted 2018-04-13T14:05:30.767

Reputation: 40 910

Thank you for answering my question. How do I determine when a block (or multiple) has become stale?androidu 2018-04-13T20:18:08.783

Maybe I should ask this as a separate postandroidu 2018-04-13T20:24:08.993