Every time a batch is finalized, we start watching for all vtxo leaves, and we also do the same whenever an offchain tx is finalized.
The purpose is to ensure we detect unrolls, and to protect against fraud, but subscribing to the entire vtxo set is just a bit overkill.
We can instead go for an "incremental watch" approach here:
- whenever a batch is finalized, we start watching for its output script until it shows up onchain, and we stop the watch as soon as it happens
- if we swept, nothing left to do; otherwise, we start watching their children
By repeating these 2 steps we end up watching only the vtxos that are actually being unrolled instead of the entire trees and virtual mempool.
Every time a batch is finalized, we start watching for all vtxo leaves, and we also do the same whenever an offchain tx is finalized.
The purpose is to ensure we detect unrolls, and to protect against fraud, but subscribing to the entire vtxo set is just a bit overkill.
We can instead go for an "incremental watch" approach here:
By repeating these 2 steps we end up watching only the vtxos that are actually being unrolled instead of the entire trees and virtual mempool.