mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 22:31:48 +01:00
jsonrpc: add deprecations command to locally set deprecated apis on/off.
This command allows more fine-grained testing, without having to change the config of the lightning node. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: JSON-RPC: `deprecations` to enable/disable deprecated APIs from this caller.
This commit is contained in:
parent
a8bdde0667
commit
2fe4ba01cd
4 changed files with 83 additions and 0 deletions
|
@ -40,6 +40,7 @@ MANPAGES := doc/lightning-cli.1 \
|
||||||
doc/lightning-delforward.7 \
|
doc/lightning-delforward.7 \
|
||||||
doc/lightning-delinvoice.7 \
|
doc/lightning-delinvoice.7 \
|
||||||
doc/lightning-delpay.7 \
|
doc/lightning-delpay.7 \
|
||||||
|
doc/lightning-deprecations.7 \
|
||||||
doc/lightning-disableinvoicerequest.7 \
|
doc/lightning-disableinvoicerequest.7 \
|
||||||
doc/lightning-disableoffer.7 \
|
doc/lightning-disableoffer.7 \
|
||||||
doc/lightning-disconnect.7 \
|
doc/lightning-disconnect.7 \
|
||||||
|
|
|
@ -46,6 +46,7 @@ Core Lightning Documentation
|
||||||
lightning-delforward <lightning-delforward.7.md>
|
lightning-delforward <lightning-delforward.7.md>
|
||||||
lightning-delinvoice <lightning-delinvoice.7.md>
|
lightning-delinvoice <lightning-delinvoice.7.md>
|
||||||
lightning-delpay <lightning-delpay.7.md>
|
lightning-delpay <lightning-delpay.7.md>
|
||||||
|
lightning-deprecations <lightning-deprecations.7.md>
|
||||||
lightning-disableinvoicerequest <lightning-disableinvoicerequest.7.md>
|
lightning-disableinvoicerequest <lightning-disableinvoicerequest.7.md>
|
||||||
lightning-disableoffer <lightning-disableoffer.7.md>
|
lightning-disableoffer <lightning-disableoffer.7.md>
|
||||||
lightning-disconnect <lightning-disconnect.7.md>
|
lightning-disconnect <lightning-disconnect.7.md>
|
||||||
|
|
49
doc/lightning-deprecations.7.md
Normal file
49
doc/lightning-deprecations.7.md
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
lightning-deprecations -- Command to enable/disable deprecated APIs
|
||||||
|
===================================================================
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
|
||||||
|
**deprecations** *enable*
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
|
||||||
|
(Added *v24.02*)
|
||||||
|
|
||||||
|
The **deprecations** RPC command overrides the global `allow-deprecated-apis` flag for further RPC commands on this same connection. In particular, setting *enable* to `false` will neither accept deprecated parameters or commands, nor output
|
||||||
|
deprecated fields.
|
||||||
|
|
||||||
|
This is equivalent to the config option `allow-deprecated-apis`, but can
|
||||||
|
be used on useful for developer testing to ensure you don't accidentally rely on
|
||||||
|
deprecated features.
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLE JSON REQUEST
|
||||||
|
--------------------
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": 82,
|
||||||
|
"method": "deprecations",
|
||||||
|
"params": {
|
||||||
|
"enable": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
RETURN VALUE
|
||||||
|
------------
|
||||||
|
|
||||||
|
On failure, one of the following error codes may be returned:
|
||||||
|
|
||||||
|
- -32602: Error in given parameters.
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
------
|
||||||
|
|
||||||
|
Rusty Russell <<rusty@blockstream.com>> wrote the initial version of this man page.
|
||||||
|
|
||||||
|
RESOURCES
|
||||||
|
---------
|
||||||
|
|
||||||
|
Main web site: <https://github.com/ElementsProject/lightning>
|
|
@ -93,6 +93,9 @@ struct json_connection {
|
||||||
jsmn_parser input_parser;
|
jsmn_parser input_parser;
|
||||||
jsmntok_t *input_toks;
|
jsmntok_t *input_toks;
|
||||||
|
|
||||||
|
/* Local deprecated support? */
|
||||||
|
bool deprecated_ok;
|
||||||
|
|
||||||
/* Our commands */
|
/* Our commands */
|
||||||
struct list_head commands;
|
struct list_head commands;
|
||||||
|
|
||||||
|
@ -654,6 +657,8 @@ struct json_filter **command_filter_ptr(struct command *cmd)
|
||||||
|
|
||||||
static bool command_deprecated_ok(const struct command *cmd)
|
static bool command_deprecated_ok(const struct command *cmd)
|
||||||
{
|
{
|
||||||
|
if (cmd->jcon)
|
||||||
|
return cmd->jcon->deprecated_ok;
|
||||||
return cmd->ld->deprecated_apis;
|
return cmd->ld->deprecated_apis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,6 +1337,7 @@ static struct io_plan *jcon_connected(struct io_conn *conn,
|
||||||
jcon->input_toks = toks_alloc(jcon);
|
jcon->input_toks = toks_alloc(jcon);
|
||||||
jcon->notifications_enabled = false;
|
jcon->notifications_enabled = false;
|
||||||
jcon->db_batching = false;
|
jcon->db_batching = false;
|
||||||
|
jcon->deprecated_ok = ld->deprecated_apis;
|
||||||
list_head_init(&jcon->commands);
|
list_head_init(&jcon->commands);
|
||||||
|
|
||||||
/* We want to log on destruction, so we free this in destructor. */
|
/* We want to log on destruction, so we free this in destructor. */
|
||||||
|
@ -1750,3 +1756,29 @@ static const struct json_command batching_command = {
|
||||||
"Database transaction batching {enable}",
|
"Database transaction batching {enable}",
|
||||||
};
|
};
|
||||||
AUTODATA(json_command, &batching_command);
|
AUTODATA(json_command, &batching_command);
|
||||||
|
|
||||||
|
static struct command_result *json_deprecations(struct command *cmd,
|
||||||
|
const char *buffer,
|
||||||
|
const jsmntok_t *obj UNNEEDED,
|
||||||
|
const jsmntok_t *params)
|
||||||
|
{
|
||||||
|
bool *enable;
|
||||||
|
|
||||||
|
if (!param(cmd, buffer, params,
|
||||||
|
p_req("enable", param_bool, &enable),
|
||||||
|
NULL))
|
||||||
|
return command_param_failed();
|
||||||
|
|
||||||
|
/* Catch the case where they sent this command then hung up. */
|
||||||
|
if (cmd->jcon)
|
||||||
|
cmd->jcon->deprecated_ok = *enable;
|
||||||
|
return command_success(cmd, json_stream_success(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct json_command deprecations_command = {
|
||||||
|
"deprecations",
|
||||||
|
"utility",
|
||||||
|
json_deprecations,
|
||||||
|
"Set/unset deprecated APIs on this JSON connection (for developer testing)",
|
||||||
|
};
|
||||||
|
AUTODATA(json_command, &deprecations_command);
|
||||||
|
|
Loading…
Add table
Reference in a new issue