emeraldpay / dshackle

Fault Tolerant Load Balancer for Ethereum and Bitcoin APIs
Apache License 2.0
298 stars 65 forks source link

Bitcoin RPC not compatible with JSON-RPC 1.0 #252

Open vdoflip opened 11 months ago

vdoflip commented 11 months ago

When calling Bitcoin RPC requests with 1.0 version, an error is returned:

> curl   -d '{"jsonrpc": "1.0",  "method":"getblockchaininfo","params":[],"id":1}' https://rpc-testnet.mydomain.xyz
/btc                                                   
{"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"Unsupported JSON RPC version: 1.0"}}

This is problematic because many Bitcoin applications and protocols still use version 1.0 for legacy and compatibility reasons. There should be an exception for Bitcoin upstreams, or an option to disable the check.

vdoflip commented 11 months ago

See: https://github.com/bitcoin/bitcoin/blob/4c57e53a61e6ae65ee87a25b1355530224b5ae9e/src/rpc/request.cpp#L23

splix commented 11 months ago

Oh, that's very unexpected. Do you have any numbers/stats/etc to find out how many outdated bitcoin nodes are here? To figure out if that makes sense to fix or better to wait until they upgrade

vdoflip commented 11 months ago

I don't have any numbers but I would expect a relatively high % of applications (not nodes) still using the 1.0 version of jsonrpc requests, even if the nodes are up to date.

To be clear, this is not an issue connecting to Bitcoin nodes (that works) it's an issue with clients connecting to Dshackle's endpoint.

vdoflip commented 11 months ago

The official RPC reference documentation still uses 1.0:

https://developer.bitcoin.org/reference/rpc/getbestblockhash.html

splix commented 11 months ago

If that's the clients, what could possible prevent them from using the version 2.0? I mean, that's their intentional decision not a limitation of something, and they can use in the requests any version they wish. I guess it's not something that should be fixed on Dshackle side, b/c the same client may choose which version they want to use.

vdoflip commented 11 months ago

Full 2.0 support in Bitcoin is WIP ATM. In my opinion 1.0 should be supported in dshackle until it's deprecated: https://github.com/bitcoin/bitcoin/pull/27101

splix commented 11 months ago

That would be a bit strange to support. I mean if everything works with v2.0, and for a client it's just a matter of decision, why wait for a deprecation which could never happen. "No deprecated" is not the same as "recommended".

vdoflip commented 11 months ago

Everything except projects that assume Bitcoin to be 1.0 and use it for legacy/compat reasons. This makes dshackle more restrictive than the RPCs that it supports, just limited by a single line of code.

I will fork then, since I have no control over the clients I'm going to use.