Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
1f6392fa83
  1. 8
      lightningd/jsonrpc.c
  2. 1
      lightningd/jsonrpc.h
  3. 5
      lightningd/options.c
  4. 3
      lightningd/options.h

8
lightningd/jsonrpc.c

@ -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,

1
lightningd/jsonrpc.h

@ -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);

5
lightningd/options.c

@ -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

3
lightningd/options.h

@ -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 */

Loading…
Cancel
Save