dshackle icon indicating copy to clipboard operation
dshackle copied to clipboard

Bitcoin RPC not compatible with JSON-RPC 1.0

Open vdoflip opened this issue 2 years ago • 8 comments

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 avatar Jul 28 '23 15:07 vdoflip

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

vdoflip avatar Jul 28 '23 15:07 vdoflip

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

splix avatar Jul 28 '23 19:07 splix

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 avatar Jul 31 '23 09:07 vdoflip

The official RPC reference documentation still uses 1.0:

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

vdoflip avatar Jul 31 '23 09:07 vdoflip

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.

splix avatar Jul 31 '23 14:07 splix

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

vdoflip avatar Jul 31 '23 14:07 vdoflip

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".

splix avatar Jul 31 '23 17:07 splix

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.

vdoflip avatar Aug 01 '23 08:08 vdoflip