@@ -711,7 +711,7 @@ static void replace_command(struct rpc_command_hook_payload *p,
711711 const char * buffer ,
712712 const jsmntok_t * replacetok )
713713{
714- const jsmntok_t * method = NULL , * params = NULL , * jsonrpc ;
714+ const jsmntok_t * method = NULL , * params = NULL ;
715715 const char * bad ;
716716
717717 /* Must contain "method", "params" and "id" */
@@ -743,10 +743,14 @@ static void replace_command(struct rpc_command_hook_payload *p,
743743 goto fail ;
744744 }
745745
746- jsonrpc = json_get_member (buffer , replacetok , "jsonrpc" );
747- if (!jsonrpc || jsonrpc -> type != JSMN_STRING || !json_tok_streq (buffer , jsonrpc , "2.0" )) {
748- bad = "jsonrpc: \"2.0\" must be specified in the request" ;
749- goto fail ;
746+ // deprecated phase to give the possibility to all to migrate and stay safe
747+ // from this more restrictive change.
748+ if (!deprecated_apis ) {
749+ const jsmntok_t * jsonrpc = json_get_member (buffer , replacetok , "jsonrpc" );
750+ if (!jsonrpc || jsonrpc -> type != JSMN_STRING || !json_tok_streq (buffer , jsonrpc , "2.0" )) {
751+ bad = "jsonrpc: \"2.0\" must be specified in the request" ;
752+ goto fail ;
753+ }
750754 }
751755
752756 was_pending (command_exec (p -> cmd -> jcon , p -> cmd , buffer , replacetok ,
@@ -883,7 +887,7 @@ REGISTER_PLUGIN_HOOK(rpc_command,
883887static struct command_result *
884888parse_request (struct json_connection * jcon , const jsmntok_t tok [])
885889{
886- const jsmntok_t * method , * id , * params , * filter , * jsonrpc ;
890+ const jsmntok_t * method , * id , * params , * filter ;
887891 struct command * c ;
888892 struct rpc_command_hook_payload * rpc_hook ;
889893 bool completed ;
@@ -912,11 +916,13 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
912916
913917 // Adding a deprecated phase to make sure that all the Core Lightning wrapper
914918 // can migrate all the frameworks
915- jsonrpc = json_get_member (jcon -> buffer , tok , "jsonrpc" );
919+ if (!deprecated_apis ) {
920+ const jsmntok_t * jsonrpc = json_get_member (jcon -> buffer , tok , "jsonrpc" );
916921
917- if (!jsonrpc || jsonrpc -> type != JSMN_STRING || !json_tok_streq (jcon -> buffer , jsonrpc , "2.0" )) {
918- json_command_malformed (jcon , "null" , "jsonrpc: \"2.0\" must be specified in the request" );
919- return NULL ;
922+ if (!jsonrpc || jsonrpc -> type != JSMN_STRING || !json_tok_streq (jcon -> buffer , jsonrpc , "2.0" )) {
923+ json_command_malformed (jcon , "null" , "jsonrpc: \"2.0\" must be specified in the request" );
924+ return NULL ;
925+ }
920926 }
921927
922928 /* Allocate the command off of the `jsonrpc` object and not
0 commit comments