bitcoindevkit / bitcoindevkit/bdk_wallet

Never panic based on remote-provided inputs

Open
#30 14 comments 0 reactions 0 assignees View on GitHub
bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.