mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
lightningd: always require "jsonrpc": "2.0" in request.
Changelog-Removed: JSONRPC: RPC framework now requires the `"jsonrpc"` property inside the request (deprecated in v0.10.2) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -677,7 +677,7 @@ static void replace_command(struct rpc_command_hook_payload *p,
|
|||||||
const char *buffer,
|
const char *buffer,
|
||||||
const jsmntok_t *replacetok)
|
const jsmntok_t *replacetok)
|
||||||
{
|
{
|
||||||
const jsmntok_t *method = NULL, *params = NULL;
|
const jsmntok_t *method = NULL, *params = NULL, *jsonrpc;
|
||||||
const char *bad;
|
const char *bad;
|
||||||
|
|
||||||
/* Must contain "method", "params" and "id" */
|
/* Must contain "method", "params" and "id" */
|
||||||
@@ -709,15 +709,11 @@ static void replace_command(struct rpc_command_hook_payload *p,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated phase to give the possibility to all to migrate and stay safe
|
jsonrpc = json_get_member(buffer, replacetok, "jsonrpc");
|
||||||
// from this more restrictive change.
|
|
||||||
if (!deprecated_apis) {
|
|
||||||
const jsmntok_t *jsonrpc = json_get_member(buffer, replacetok, "jsonrpc");
|
|
||||||
if (!jsonrpc || jsonrpc->type != JSMN_STRING || !json_tok_streq(buffer, jsonrpc, "2.0")) {
|
if (!jsonrpc || jsonrpc->type != JSMN_STRING || !json_tok_streq(buffer, jsonrpc, "2.0")) {
|
||||||
bad = "jsonrpc: \"2.0\" must be specified in the request";
|
bad = "jsonrpc: \"2.0\" must be specified in the request";
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
was_pending(command_exec(p->cmd->jcon, p->cmd, buffer, replacetok,
|
was_pending(command_exec(p->cmd->jcon, p->cmd, buffer, replacetok,
|
||||||
params));
|
params));
|
||||||
@@ -853,7 +849,7 @@ REGISTER_PLUGIN_HOOK(rpc_command,
|
|||||||
static struct command_result *
|
static struct command_result *
|
||||||
parse_request(struct json_connection *jcon, const jsmntok_t tok[])
|
parse_request(struct json_connection *jcon, const jsmntok_t tok[])
|
||||||
{
|
{
|
||||||
const jsmntok_t *method, *id, *params;
|
const jsmntok_t *method, *id, *params, *jsonrpc;
|
||||||
struct command *c;
|
struct command *c;
|
||||||
struct rpc_command_hook_payload *rpc_hook;
|
struct rpc_command_hook_payload *rpc_hook;
|
||||||
bool completed;
|
bool completed;
|
||||||
@@ -881,14 +877,12 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
|
|||||||
|
|
||||||
// Adding a deprecated phase to make sure that all the Core Lightning wrapper
|
// Adding a deprecated phase to make sure that all the Core Lightning wrapper
|
||||||
// can migrate all the frameworks
|
// can migrate all the frameworks
|
||||||
if (!deprecated_apis) {
|
jsonrpc = json_get_member(jcon->buffer, tok, "jsonrpc");
|
||||||
const jsmntok_t *jsonrpc = json_get_member(jcon->buffer, tok, "jsonrpc");
|
|
||||||
|
|
||||||
if (!jsonrpc || jsonrpc->type != JSMN_STRING || !json_tok_streq(jcon->buffer, jsonrpc, "2.0")) {
|
if (!jsonrpc || jsonrpc->type != JSMN_STRING || !json_tok_streq(jcon->buffer, jsonrpc, "2.0")) {
|
||||||
json_command_malformed(jcon, "null", "jsonrpc: \"2.0\" must be specified in the request");
|
json_command_malformed(jcon, "null", "jsonrpc: \"2.0\" must be specified in the request");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate the command off of the `jsonrpc` object and not
|
/* Allocate the command off of the `jsonrpc` object and not
|
||||||
* the connection since the command may outlive `conn`. */
|
* the connection since the command may outlive `conn`. */
|
||||||
|
|||||||
Reference in New Issue
Block a user