Skip to content

Better error messages are needed when debugging Bitcoin node RPC #32

@rkuester

Description

@rkuester

403s, connection failures, and other Bitcoin node errors should result in informative error messages that help users diagnose problems in their specific context. I encountered misleading errors when setting up Hydrapool in Docker following the README.

Because Hydrapool's Docker network wasn't in an rpcallowip range in Bitcoin Core's bitcoin.conf (as documented in #31), bitcoind returned 403 Forbidden. Hydrapool panicked with this error:

thread 'tokio-runtime-worker' panicked at /usr/local/cargo/git/checkouts/p2poolv2-a1a70bd60bcd2d3a/05554b8/p2poolv2_lib/src/stratum/work/gbt.rs:105:54:
called Result::unwrap() on an Err value: Other("Failed to parse response: error decoding response body")

The error blamed JSON parsing when the real issue was a 403 HTTP status code. The response body was empty (because of the 403), which caused the JSON parser to fail. This made diagnosis very difficult, especially when running a pre-built Hydrapool container where modifying p2poolv2_lib's source wasn't straightforward.

I added extensive debug logging to p2poolv2/bitcoindrpc and augmented the error strings returned via BitcoindRpcError. This let me see the actual 403 status and other diagnostic information at debug log level. My changes are here: 96eebfb (for reference—not production-ready).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions