Add disconnect-block functionality for `LocalChain` and `Wallet`
Describe the enhancement
impl LocalChain {
/// Removes blocks from the given `block_id`.
///
/// Will remove blocks with a height equal or greater than `block_id`,
/// but only if `block_id` exists in the chain.
pub fn disconnect_block(&mut self, block_id: BlockId) -> ChangeSet {
todo!()
}
}
Use case
The APIs of utreexod (based on btcd) and bitcoind ZeroMQ has disconnect-block notifications. BDK should be able to handle such notifications.
post fix concept NACK. I interpret these messages are informational (something to log out). You just need to wait for the block that replaces it which will automatically evict the block. Eagerly evicting blocks means you end up in a state where your wallet says it has less money than it actually does. This could be unexpected and harmful -- imagine you have a emergency notification that goes out to the whole company if there is a sudden drop in Bitcoin holdings. If you just wait for the new block any funds you received in the evicted block are likely to appear in the new one so you never end up in this state.
Is there some motivation for reacting to these messages that I'm missing?
looks like this was fixed with #1276.
I'm guessing you didn't see my comment above where I question whether we should actually do this. If you think I should make a new issue let me know.
@LLFourn sorry about that, no need to create a new issue. I just saw the closed related issue and didn't see your first reopen for this one.
@evanlinjin based on Lloyd's reasoning should we revert #1276 or is there some particular use case for this new function, such as for utrexo that can't wait for a new block to evict reorg'd out blocks?
If there is a reason to keep this function that everyone agrees on it sounds like we should at least add a strong warning in the docs that it could cause inaccurate utxo balances if misused.