Accept optional server.version arguments per the protocol - #1328
Open
pucedoteth wants to merge 1 commit into
Open
Accept optional server.version arguments per the protocol#1328pucedoteth wants to merge 1 commit into
pucedoteth wants to merge 1 commit into
Conversation
Both `client_name` and `protocol_version` are optional in the Electrum protocol, defaulting to "" and "1.4". `Params::Version` required a two-element tuple, so `server.version` with no arguments or with only `client_name` was rejected as invalid params before the handler ran. Use the same untagged-arity enum the other optional-argument methods use, and default the omitted `protocol_version` to "1.4".
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.
The Electrum protocol declares both
server.versionarguments as optional:Params::Versionheld a required(String, VersionRequest), so anything short of two arguments failed to deserialize and the request was rejected withinvalid paramsbeforeversion()ran. On master:This mirrors the fix in #1325 for
blockchain.transaction.id_from_pos:VersionArgsis an untagged arity enum, the same shape already used byTxGetArgs,TxFromPosArgsandBroadcastArgs. An omittedprotocol_versiondefaults to"1.4"as the protocol specifies, rather than toPROTOCOL_VERSION, so the negotiation still runs throughcheck_betweenand would correctly reject a client that relies on the default if the server's supported version ever moves past 1.4.Tests follow the pattern of
test_tx_from_pos_args/test_params_id_from_pos: one covering the aritiesVersionArgsaccepts (and that malformed params are still rejected), one covering the dispatcher. Both fail on master withfailed to parse [].cargo test --libpasses (11 tests),cargo fmt --all --checkis clean, andcargo clippy --all-targets -- -D warningsreports nothing.Out of scope, noted in case you want it: a request that omits the
paramsmember entirely arrives asValue::Nullrather than[], which this does not accept. That affects every method, not justserver.version, so it seemed better kept separate.Disclosure: written with AI assistance; the analysis, fix and tests were verified locally.