mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-10 09:34:22 +01:00
lightningd: --deprecated-api option to turn off deprecated APIs.
This can be used for upgrades to make sure you're not using deprecated options, JSON commands, JSON fields, etc. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <lightningd/jsonrpc.h>
|
||||
#include <lightningd/lightningd.h>
|
||||
#include <lightningd/log.h>
|
||||
#include <lightningd/options.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -526,6 +527,13 @@ static void parse_request(struct json_connection *jcon, const jsmntok_t tok[])
|
||||
jcon->buffer + method->start);
|
||||
return;
|
||||
}
|
||||
if (cmd->deprecated && !deprecated_apis) {
|
||||
command_fail(jcon->current,
|
||||
"command '%.*s' is deprecated",
|
||||
(int)(method->end - method->start),
|
||||
jcon->buffer + method->start);
|
||||
return;
|
||||
}
|
||||
|
||||
if (params->type != JSMN_ARRAY && params->type != JSMN_OBJECT) {
|
||||
command_fail(jcon->current,
|
||||
|
||||
@@ -53,6 +53,7 @@ struct json_command {
|
||||
const char *buffer, const jsmntok_t *params);
|
||||
const char *description;
|
||||
const char *help;
|
||||
bool deprecated;
|
||||
};
|
||||
|
||||
struct json_result *null_response(const tal_t *ctx);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <unistd.h>
|
||||
#include <wire/wire.h>
|
||||
|
||||
bool deprecated_apis = true;
|
||||
|
||||
/* Tal wrappers for opt. */
|
||||
static void *opt_allocfn(size_t size)
|
||||
{
|
||||
@@ -269,6 +271,9 @@ static void config_register_opts(struct lightningd *ld)
|
||||
ld,
|
||||
"Select the network parameters (bitcoin, testnet,"
|
||||
" regtest, or litecoin)");
|
||||
opt_register_arg("--deprecated-apis", opt_set_bool_arg, opt_show_bool,
|
||||
&deprecated_apis,
|
||||
"Enable deprecated options, JSONRPC commands, fields, etc.");
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
|
||||
@@ -15,4 +15,7 @@ bool handle_opts(struct lightningd *ld, int argc, char *argv[]);
|
||||
|
||||
/* Derive default color and alias from the pubkey. */
|
||||
void setup_color_and_alias(struct lightningd *ld);
|
||||
|
||||
/* Global to allow deprecated options. */
|
||||
extern bool deprecated_apis;
|
||||
#endif /* LIGHTNING_LIGHTNINGD_OPTIONS_H */
|
||||
|
||||
Reference in New Issue
Block a user