Skip to content

Never panic based on remote-provided inputs #30

Open
bitcoindevkit/bdk
#1981
@tnull

Description

@tnull

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions