Repository navigation
Conversation
Electrum protocol v1.6 mandates that the first message a client sends
must be `server.version`. Enforce this in electrs:
- Add `negotiated_version: Option<String>` to the per-client state.
- Set it inside `fn version()` once the version handshake succeeds.
- In `single_call`, reject any non-Version call when
`negotiated_version` is still `None`, with a JSON-RPC error message
that names the required method.
Behavior change for clients: anything that today sends `server.ping`,
`server.banner`, etc. before the version handshake will start receiving
an error. This matches the v1.6 specification and aligns electrs with
the rest of the ecosystem.
Spec: https://electrum-protocol.readthedocs.io/en/latest/protocol-changes.html#version-1-6
Refs romanz#1241
PeterXMR
force-pushed
the
server-version-first-1241
branch
from
September 17, 2026 20:57
03b4049 to
5fcda99
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1241 — checks off the
server.version()must-be-first-message item on the v1.6 protocol checklist.Summary
Electrum protocol v1.6 mandates that
server.versionis the first message a client sends. Enforce this in electrs.negotiated_version: Option<String>to the per-client state (Client)fn version()once the version handshake succeedssingle_call, reject any non-Version call whennegotiated_version.is_none()with a JSON-RPC error that names the required methodAny client that today sends
server.ping/server.banner/server.features/ etc. before the version handshake will start receiving an error. This is a deliberate v1.6 spec-compliance change.Happy to soften this to a
warn!-then-allow if you'd prefer a phased rollout — let me know.Test plan
test_client_starts_without_negotiated_versionconfirms the default-Nonestate the gate keys oncargo test --lib— 22/22 passcargo clippy --all-targets -- -D warnings— cleancargo fmt --check— clean