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

[Feature] Version negotiation #59

Open
Beanow opened this issue Sep 28, 2021 · 1 comment
Open

[Feature] Version negotiation #59

Beanow opened this issue Sep 28, 2021 · 1 comment

Comments

@Beanow
Copy link

Beanow commented Sep 28, 2021

Trying to connect to a BTG server at tcp://electrumx-eu.bitcoingold.org:50001 I found the server is rather old.

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

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

@Beanow
Copy link
Author

Beanow commented Sep 28, 2021

Update, BTG specifically is unlikely to work without changes to the bitcoin crate, as they've substantially changed the block header format. That said, it may still be an interesting forward compatibility feature.

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