What's the most efficient way to detect a fork in the blockchain?
My app polls for changes to user deposit addresses on each new block.
Deposits are credited to user accounts with a record in a database then the funds are transfered to cold storage.
When users get refunds those refunds come from the cold storage and a record is added to the database.
My concern is the following happening:
- User deposits Btc and the database record is created.
- Chain is forked from 51% attack or software incompatability.
- User gets refund from cold storage but I no longer have access to the funds they sent so its out of my pocket.
It seems that everything but rechecking every deposit is marginally risky.
If I rely on height plus hash that can be manufactured by the attacker so the new chain looks like the old chain.