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?

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.

  • Thank you for answering my question. How do I determine when a block (or multiple) has become stale? – androidu Apr 13 '18 at 20:18
  • Maybe I should ask this as a separate post – androidu Apr 13 '18 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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