LLFourn / bdk_core_staging

Staging area for bdk_core initial development
15 stars 12 forks source link

Esplora and Electrum should not have Reorg error #184

Open LLFourn opened 1 year ago

LLFourn commented 1 year ago

Just because there's a re-org during a scan does not mean we have to fail it I think.

Instead we can just recursively call the function but instead of doing a script based scan we do a txid based scan where we pass in all the related txids we found during the failed scan to find out where they currently reside post re-org. This guarantees we can return a valid chain and txs with consistent positions in that chain. This technique does not guarantee that you get the same output as if you had done a full rescan after the re-org (it may have less info) but doing a full re-scan would require the script iterators passed to be Clone so we could start again. Making them Clone is annoying for the caller and makes it harder to monitor progress by iterator consumption.

The solution suggested here requires #84 be done first (or rather at the same time).