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
Describe the bug
I just hit a panic in
bdk_esploraas I misconfigured the URL for the Esplora endpoint to a server on a different network (i.e., left it untouched when switching networks frommainnettosignet). This results in in hitting thisexpect: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
expectandunwrapin 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
expectorunwrap. Given that all of these methods returnResult<.., 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