Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electrum: error property in response is not JSON-RPC 2.0 compliant #453

Open
nkuba opened this issue May 16, 2023 · 0 comments
Open

Electrum: error property in response is not JSON-RPC 2.0 compliant #453

nkuba opened this issue May 16, 2023 · 0 comments

Comments

@nkuba
Copy link

nkuba commented May 16, 2023

Errors returned by the Electrum JSON-RPC API in esplora-electrs are not following the JSON-RPC 2.0 Specification which causes clients integration problems (e.g. checksum0/go-electrum#5).

An error is returned as a string while an error object is expected.

Sample output for esplora-electrs:

echo '{"jsonrpc": "2.0", "method": "server.version", "id": 0}' | netcat 49.12.127.114 10068
{"jsonrpc":"2.0","result":["ElectrumX 1.16.0","1.4"],"id":0}

✗ echo '{"jsonrpc": "2.0", "method": "blockchain.block.header", "params": [4294967295], "id": 0}' | netcat 35.225.54.191 50001
{"error":"missing header","id":0,"jsonrpc":"2.0"}

Alternative Electrum server implementations follow the standard. Examples:
- ElectrumX

echo '{"jsonrpc": "2.0", "method": "server.version", "id": 0}' | netcat 49.12.127.114 10068
{"jsonrpc":"2.0","result":["ElectrumX 1.16.0","1.4"],"id":0}

✗ echo '{"jsonrpc": "2.0", "method": "blockchain.block.header", "params": [4294967295], "id": 0}' | netcat 49.12.127.114 10068
{"jsonrpc":"2.0","error":{"code":1,"message":"height 4,294,967,295 out of range"},"id":0}

- Fulcrum

echo '{"jsonrpc": "2.0", "method": "server.version", "id": 0}' | netcat 203.132.94.196 51001
{"id":0,"jsonrpc":"2.0","result":["Fulcrum 1.8.2","1.4"]}

✗ echo '{"jsonrpc": "2.0", "method": "blockchain.block.header", "params": [4294967295], "id": 0}' | netcat 203.132.94.196 51001
{"error":{"code":1,"message":"Invalid height"},"id":0,"jsonrpc":"2.0"}
nkuba added a commit to keep-network/go-electrum that referenced this issue May 16, 2023
Here we provide a workaround for servers that don't follow
the JSON-RPC 2.0 specification for error objects.

According to the specification, error should be an object
containing `code`, `message`, and `data` properties
(see: https://www.jsonrpc.org/specification#error_object).
Unfortunatelly Electrs returns error as a string
(see: Blockstream/esplora#453).

We define an error unmarshaling function to handle both types
of errors.
nkuba added a commit to keep-network/go-electrum that referenced this issue May 16, 2023
Here we provide a workaround for servers that don't follow the
JSON-RPC 2.0 specification for error objects.

According to the specification, an error should be an object
containing `code`, `message`, and `data` properties
(see: https://www.jsonrpc.org/specification#error_object).
Unfortunately, Electrs returns an error as a string
(see: Blockstream/esplora#453).

We define an error unmarshaling function to handle both types of errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant