bitcoindevkit / bitcoindevkit/bdk_wallet
Never panic based on remote-provided inputs
- Dominant language
- Rust
- Stars
- 59
- Forks
- 105
- Avg merge
- 10d 9h
- Merged PRs (30d)
- 1
Description
**Describe the bug**
I just hit a panic in `bdk_esplora` as I misconfigured the URL for the Esplora endpoint to a server on a different network (i.e., left it untouched when switching networks from `mainnet` to `signet`). This results in in hitting this `expect`:
https://github.com/bitcoindevkit/bdk/blob/88330f603cb415d01c88f1a579f20a21cb8c1658/crates/esplora/src/async_ext.rs#L240
While this is just a minor inconvenience, it surfaces a much larger problem: from a quick look, there are many cases of `expect` and `unwrap` in the chain-syncing crates (i.e., `bdk_esplora`,`bdk_electrum`), and at least a few of them seem to be directly or indirectly based on remote-provided inputs that aren't validated otherwise.
This should never happen, essentially crates dealing with remote-provided data should *never* `expect` or `unwrap`. Given that all of these methods return `Result<.., Error>` there really is no reason why they couldn't just return errors in these cases.
**To Reproduce**
For example, switch networks without switching Esplora URLs.
**Expected behavior**
Never panic based on remote-provided inputs
Contributor guide
Assessment
This issue has not been assessed yet.