bitcoindevkit / bitcoindevkit/rust-electrum-client
[Feature] Version negotiation
- Dominant language
- Rust
- Stars
- 89
- Forks
- 82
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 1
Description
Trying to connect to a BTG server at `tcp://electrumx-eu.bitcoingold.org:50001` I found the server is rather old.
```json
{"jsonrpc": "2.0", "method": "server.features", "params": [], "id": 2}
{"jsonrpc": "2.0", "result": {"hosts": {"electrumx-eu.bitcoingold.org": {"tcp_port": 50001, "ssl_port": 50002}}, "pruning": null, "server_version": "ElectrumX 1.8.12", "protocol_min": "1.2", "protocol_max": "1.4", "genesis_hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", "hash_function": "sha256"}, "id": 2}
```
Because of this, it defaults to Electrum protocol `1.2` which isn't compatible with this client.
We can negotiate version `1.4` though, as per https://electrumx.readthedocs.io/en/latest/protocol-basics.html#version-negotiation
```json
{"jsonrpc": "2.0", "method": "server.version", "params": {"client_name": "telnet", "protocol_version": "1.4"}, "id": 5}
{"jsonrpc": "2.0", "result": ["ElectrumX 1.8.12", "1.4"], "id": 5}
```
Not only would this fix issues with the old server, it also future proofs the client for servers in the wild that may default to newer protocol versions than are supported. Plus it can give specific error messages when there's a compatibility issue.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.