mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
lightningd: remove deprecated_apis global, put into lightningd.
We usually have access to `ld`, so avoid the global. The only place generic code needs it is for the json command struct, and that already has accessors: add one for libplugin and lightningd to tell it if deprecated apis are OK. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
db7c608e2d
commit
0c4426a349
28 changed files with 80 additions and 59 deletions
|
@ -13,7 +13,6 @@
|
|||
#include <common/utils.h>
|
||||
#include <common/version.h>
|
||||
|
||||
bool deprecated_apis = true;
|
||||
int opt_exitcode = 1;
|
||||
|
||||
/* The regrettable globals */
|
||||
|
@ -346,13 +345,6 @@ struct configvar **initial_config_opts(const tal_t *ctx,
|
|||
/* Handle --version (and exit) here too */
|
||||
opt_register_version();
|
||||
|
||||
/* For convenience, we set deprecated_apis and rpc_filename now, too */
|
||||
clnopt_witharg("--allow-deprecated-apis",
|
||||
OPT_EARLY|OPT_SHOWBOOL,
|
||||
opt_set_bool_arg, opt_show_bool,
|
||||
&deprecated_apis,
|
||||
"Enable deprecated options, JSONRPC commands, fields, etc.");
|
||||
|
||||
/* Allow them to override rpc-file too. */
|
||||
*rpc_filename = default_rpcfile(ctx);
|
||||
opt_register_early_arg("--rpc-file", opt_set_talstr, opt_show_charp,
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
#include "config.h"
|
||||
#include <ccan/tal/tal.h>
|
||||
|
||||
/* Put things we're going to get rid of behind this, so testers can catch
|
||||
* them early. */
|
||||
extern bool deprecated_apis;
|
||||
|
||||
/* Unless overridden, we exit with status 1 when option parsing fails */
|
||||
extern int opt_exitcode;
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@ command_fail_badparam(struct command *cmd,
|
|||
/* Also caller supplied: is this invoked simply to get usage? */
|
||||
bool command_usage_only(const struct command *cmd);
|
||||
|
||||
/* Do we allow deprecated apis? */
|
||||
bool command_deprecated_apis(const struct command *cmd);
|
||||
|
||||
/* If so, this is called. */
|
||||
void command_set_usage(struct command *cmd, const char *usage);
|
||||
|
||||
|
|
|
@ -115,7 +115,8 @@ static struct command_result *parse_by_position(struct command *cmd,
|
|||
return post_check(cmd, params);
|
||||
}
|
||||
|
||||
static struct param *find_param(struct param *params, const char *start,
|
||||
static struct param *find_param(struct command *cmd,
|
||||
struct param *params, const char *start,
|
||||
size_t n)
|
||||
{
|
||||
struct param *first = params;
|
||||
|
@ -125,11 +126,11 @@ static struct param *find_param(struct param *params, const char *start,
|
|||
size_t arglen = strcspn(first->name, "|");
|
||||
if (memeq(first->name, arglen, start, n))
|
||||
return first;
|
||||
if (deprecated_apis
|
||||
&& first->name[arglen]
|
||||
if (first->name[arglen]
|
||||
&& memeq(first->name + arglen + 1,
|
||||
strlen(first->name + arglen + 1),
|
||||
start, n))
|
||||
start, n)
|
||||
&& command_deprecated_apis(cmd))
|
||||
return first;
|
||||
first++;
|
||||
}
|
||||
|
@ -146,7 +147,7 @@ static struct command_result *parse_by_name(struct command *cmd,
|
|||
const jsmntok_t *t;
|
||||
|
||||
json_for_each_obj(i, t, tokens) {
|
||||
struct param *p = find_param(params, buffer + t->start,
|
||||
struct param *p = find_param(cmd, params, buffer + t->start,
|
||||
t->end - t->start);
|
||||
if (!p) {
|
||||
if (!allow_extra) {
|
||||
|
|
|
@ -15,6 +15,9 @@ struct command;
|
|||
/* Generated stub for command_check_only */
|
||||
bool command_check_only(const struct command *cmd UNNEEDED)
|
||||
{ fprintf(stderr, "command_check_only called!\n"); abort(); }
|
||||
/* Generated stub for command_deprecated_apis */
|
||||
bool command_deprecated_apis(const struct command *cmd UNNEEDED)
|
||||
{ fprintf(stderr, "command_deprecated_apis called!\n"); abort(); }
|
||||
/* Generated stub for command_fail */
|
||||
struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_errcode code UNNEEDED,
|
||||
const char *fmt UNNEEDED, ...)
|
||||
|
|
|
@ -47,6 +47,9 @@ struct amount_sat amount_tx_fee(u32 fee_per_kw UNNEEDED, size_t weight UNNEEDED)
|
|||
/* Generated stub for command_check_only */
|
||||
bool command_check_only(const struct command *cmd UNNEEDED)
|
||||
{ fprintf(stderr, "command_check_only called!\n"); abort(); }
|
||||
/* Generated stub for command_deprecated_apis */
|
||||
bool command_deprecated_apis(const struct command *cmd UNNEEDED)
|
||||
{ fprintf(stderr, "command_deprecated_apis called!\n"); abort(); }
|
||||
/* Generated stub for command_fail */
|
||||
struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_errcode code UNNEEDED,
|
||||
const char *fmt UNNEEDED, ...)
|
||||
|
@ -58,8 +61,6 @@ void command_set_usage(struct command *cmd UNNEEDED, const char *usage UNNEEDED)
|
|||
/* Generated stub for command_usage_only */
|
||||
bool command_usage_only(const struct command *cmd UNNEEDED)
|
||||
{ fprintf(stderr, "command_usage_only called!\n"); abort(); }
|
||||
/* Generated stub for deprecated_apis */
|
||||
bool deprecated_apis;
|
||||
/* Generated stub for fromwire */
|
||||
const u8 *fromwire(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, void *copy UNNEEDED, size_t n UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire called!\n"); abort(); }
|
||||
|
|
|
@ -40,8 +40,6 @@ struct command_result *command_fail(struct command *cmd,
|
|||
/* Generated stub for command_filter_ptr */
|
||||
struct json_filter **command_filter_ptr(struct command *cmd UNNEEDED)
|
||||
{ fprintf(stderr, "command_filter_ptr called!\n"); abort(); }
|
||||
/* Generated stub for deprecated_apis */
|
||||
bool deprecated_apis;
|
||||
/* Generated stub for fromwire_tlv */
|
||||
bool fromwire_tlv(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
|
||||
const struct tlv_record_type *types UNNEEDED, size_t num_types UNNEEDED,
|
||||
|
@ -64,6 +62,7 @@ enum command_mode {
|
|||
|
||||
struct command {
|
||||
enum command_mode mode;
|
||||
bool deprecated_apis;
|
||||
const char *usage;
|
||||
};
|
||||
|
||||
|
@ -82,6 +81,11 @@ bool command_check_only(const struct command *cmd)
|
|||
return cmd->mode == CMD_CHECK;
|
||||
}
|
||||
|
||||
bool command_deprecated_apis(const struct command *cmd)
|
||||
{
|
||||
return cmd->deprecated_apis;
|
||||
}
|
||||
|
||||
struct json {
|
||||
jsmntok_t *toks;
|
||||
char *buffer;
|
||||
|
@ -446,12 +450,12 @@ static void deprecated_rename(void)
|
|||
NULL));
|
||||
assert(*u64 == 42);
|
||||
|
||||
deprecated_apis = true;
|
||||
cmd->deprecated_apis = true;
|
||||
j = json_parse(cmd, "{ 'old_u64': 42 }");
|
||||
assert(param(cmd, j->buffer, j->toks,
|
||||
p_req("u64|old_u64", param_u64, &u64),
|
||||
NULL));
|
||||
deprecated_apis = false;
|
||||
cmd->deprecated_apis = false;
|
||||
assert(!param(cmd, j->buffer, j->toks,
|
||||
p_req("u64|old_u64", param_u64, &u64),
|
||||
NULL));
|
||||
|
|
|
@ -309,7 +309,7 @@ static void estimatefees_callback(const char *buf, const jsmntok_t *toks,
|
|||
"feerates"),
|
||||
&floor);
|
||||
} else {
|
||||
if (!deprecated_apis)
|
||||
if (!call->bitcoind->ld->deprecated_apis)
|
||||
bitcoin_plugin_error(call->bitcoind, buf, resulttok,
|
||||
"estimatefees",
|
||||
"missing fee_floor field");
|
||||
|
|
|
@ -711,7 +711,7 @@ static struct command_result *json_feerates(struct command *cmd,
|
|||
if (rate)
|
||||
json_add_num(response, "penalty",
|
||||
feerate_to_style(rate, *style));
|
||||
if (deprecated_apis) {
|
||||
if (cmd->ld->deprecated_apis) {
|
||||
rate = delayed_to_us_feerate(topo);
|
||||
if (rate)
|
||||
json_add_num(response, "delayed_to_us",
|
||||
|
|
|
@ -271,7 +271,7 @@ static struct command_result *json_listconfigs(struct command *cmd,
|
|||
|
||||
response = json_stream_success(cmd);
|
||||
|
||||
if (!deprecated_apis)
|
||||
if (!cmd->ld->deprecated_apis)
|
||||
goto modern;
|
||||
|
||||
if (!config)
|
||||
|
|
|
@ -699,7 +699,7 @@ int connectd_init(struct lightningd *ld)
|
|||
ld->config.connection_timeout_secs,
|
||||
websocket_helper_path,
|
||||
ld->websocket_port,
|
||||
!deprecated_apis,
|
||||
!ld->deprecated_apis,
|
||||
IFDEV(ld->dev_fast_gossip, false),
|
||||
IFDEV(ld->dev_disconnect_fd >= 0, false),
|
||||
IFDEV(ld->dev_no_ping_timer, false));
|
||||
|
|
|
@ -82,7 +82,7 @@ static struct command_result *param_feerate_unchecked(struct command *cmd,
|
|||
|
||||
if (!json_tok_streq(buffer, tok, feerate_name(i)))
|
||||
continue;
|
||||
if (!deprecated_apis)
|
||||
if (!cmd->ld->deprecated_apis)
|
||||
return command_fail_badparam(cmd, name, buffer, tok,
|
||||
"removed feerate by names");
|
||||
switch (i) {
|
||||
|
|
|
@ -258,7 +258,7 @@ static const u8 *hook_gives_failmsg(const tal_t *ctx,
|
|||
return failmsg;
|
||||
}
|
||||
|
||||
if (!deprecated_apis)
|
||||
if (!ld->deprecated_apis)
|
||||
return NULL;
|
||||
|
||||
t = json_get_member(buffer, toks, "failure_code");
|
||||
|
|
|
@ -332,7 +332,7 @@ static void json_add_help_command(struct command *cmd,
|
|||
char *usage;
|
||||
|
||||
/* If they disallow deprecated APIs, don't even list them */
|
||||
if (!deprecated_apis && json_command->deprecated)
|
||||
if (!cmd->ld->deprecated_apis && json_command->deprecated)
|
||||
return;
|
||||
|
||||
usage = tal_fmt(cmd, "%s%s %s",
|
||||
|
@ -400,7 +400,7 @@ static struct command_result *json_help(struct command *cmd,
|
|||
return command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND,
|
||||
"Unknown command %s",
|
||||
cmdname);
|
||||
if (!deprecated_apis && one_cmd->deprecated)
|
||||
if (!cmd->ld->deprecated_apis && one_cmd->deprecated)
|
||||
return command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND,
|
||||
"Deprecated command %s",
|
||||
cmdname);
|
||||
|
@ -959,7 +959,7 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
|
|||
c, JSONRPC2_METHOD_NOT_FOUND, "Unknown command '%.*s'",
|
||||
method->end - method->start, jcon->buffer + method->start);
|
||||
}
|
||||
if (c->json_cmd->deprecated && !deprecated_apis) {
|
||||
if (c->json_cmd->deprecated && !jcon->ld->deprecated_apis) {
|
||||
return command_fail(c, JSONRPC2_METHOD_NOT_FOUND,
|
||||
"Command %.*s is deprecated",
|
||||
json_tok_full_len(method),
|
||||
|
@ -1265,6 +1265,11 @@ bool command_usage_only(const struct command *cmd)
|
|||
return cmd->mode == CMD_USAGE;
|
||||
}
|
||||
|
||||
bool command_deprecated_apis(const struct command *cmd)
|
||||
{
|
||||
return cmd->ld->deprecated_apis;
|
||||
}
|
||||
|
||||
void command_set_usage(struct command *cmd, const char *usage TAKES)
|
||||
{
|
||||
usage = tal_strdup(cmd->ld, usage);
|
||||
|
|
|
@ -255,6 +255,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
|||
ld->pure_tor_setup = false;
|
||||
ld->tor_service_password = NULL;
|
||||
ld->websocket_port = 0;
|
||||
ld->deprecated_apis = true;
|
||||
|
||||
/*~ This is initialized later, but the plugin loop examines this,
|
||||
* so set it to NULL explicitly now. */
|
||||
|
|
|
@ -106,6 +106,9 @@ struct lightningd {
|
|||
/* The directory to find all the subdaemons. */
|
||||
const char *daemon_dir;
|
||||
|
||||
/* Are deprecated APIs enabled? */
|
||||
bool deprecated_apis;
|
||||
|
||||
/* If we told to run in the background, this is our parent fd, otherwise
|
||||
* -1. */
|
||||
int daemon_parent_fd;
|
||||
|
|
|
@ -198,6 +198,7 @@ void notify_invoice_creation(struct lightningd *ld, struct amount_msat *amount,
|
|||
|
||||
/* FIXME: Use outpoint here! */
|
||||
static void channel_opened_notification_serialize(struct json_stream *stream,
|
||||
struct lightningd *ld,
|
||||
struct node_id *node_id,
|
||||
struct amount_sat *funding_sat,
|
||||
struct bitcoin_txid *funding_txid,
|
||||
|
@ -207,7 +208,7 @@ static void channel_opened_notification_serialize(struct json_stream *stream,
|
|||
json_add_node_id(stream, "id", node_id);
|
||||
json_add_amount_sat_msat(stream, "funding_msat", *funding_sat);
|
||||
json_add_txid(stream, "funding_txid", funding_txid);
|
||||
if (deprecated_apis)
|
||||
if (ld->deprecated_apis)
|
||||
json_add_bool(stream, "funding_locked", channel_ready);
|
||||
json_add_bool(stream, "channel_ready", channel_ready);
|
||||
json_object_end(stream);
|
||||
|
@ -221,6 +222,7 @@ void notify_channel_opened(struct lightningd *ld, struct node_id *node_id,
|
|||
bool channel_ready)
|
||||
{
|
||||
void (*serialize)(struct json_stream *,
|
||||
struct lightningd *,
|
||||
struct node_id *,
|
||||
struct amount_sat *,
|
||||
struct bitcoin_txid *,
|
||||
|
@ -228,7 +230,7 @@ void notify_channel_opened(struct lightningd *ld, struct node_id *node_id,
|
|||
|
||||
struct jsonrpc_notification *n
|
||||
= jsonrpc_notification_start(NULL, channel_opened_notification_gen.topic);
|
||||
serialize(n->stream, node_id, funding_sat, funding_txid, channel_ready);
|
||||
serialize(n->stream, ld, node_id, funding_sat, funding_txid, channel_ready);
|
||||
jsonrpc_notification_end(n);
|
||||
plugins_notify(ld->plugins, take(n));
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ static char *opt_set_accept_extra_tlv_types(const char *arg,
|
|||
{
|
||||
char *ret, **elements = tal_strsplit(tmpctx, arg, ",", STR_NO_EMPTY);
|
||||
|
||||
if (!deprecated_apis)
|
||||
if (!ld->deprecated_apis)
|
||||
return "Please use --accept-htlc-tlv-type multiple times";
|
||||
for (int i = 0; elements[i] != NULL; i++) {
|
||||
ret = opt_add_accept_htlc_tlv(elements[i],
|
||||
|
@ -275,7 +275,7 @@ static char *opt_add_addr_withtype(const char *arg,
|
|||
case ADDR_TYPE_TOR_V3:
|
||||
switch (ala) {
|
||||
case ADDR_LISTEN:
|
||||
if (!deprecated_apis)
|
||||
if (!ld->deprecated_apis)
|
||||
return tal_fmt(tmpctx,
|
||||
"Don't use --bind-addr=%s, use --announce-addr=%s",
|
||||
arg, arg);
|
||||
|
@ -287,7 +287,7 @@ static char *opt_add_addr_withtype(const char *arg,
|
|||
/* And we ignore it */
|
||||
return NULL;
|
||||
case ADDR_LISTEN_AND_ANNOUNCE:
|
||||
if (!deprecated_apis)
|
||||
if (!ld->deprecated_apis)
|
||||
return tal_fmt(tmpctx,
|
||||
"Don't use --addr=%s, use --announce-addr=%s",
|
||||
arg, arg);
|
||||
|
@ -332,7 +332,7 @@ static char *opt_add_addr_withtype(const char *arg,
|
|||
return tal_fmt(tmpctx,
|
||||
"Cannot announce sockets, try --bind-addr=%s", arg);
|
||||
case ADDR_LISTEN_AND_ANNOUNCE:
|
||||
if (!deprecated_apis)
|
||||
if (!ld->deprecated_apis)
|
||||
return tal_fmt(tmpctx, "Don't use --addr=%s, use --bind-addr=%s",
|
||||
arg, arg);
|
||||
ala = ADDR_LISTEN;
|
||||
|
@ -1158,7 +1158,7 @@ static char *opt_set_websocket_port(const char *arg, struct lightningd *ld)
|
|||
u32 port COMPILER_WANTS_INIT("9.3.0 -O2");
|
||||
char *err;
|
||||
|
||||
if (!deprecated_apis)
|
||||
if (!ld->deprecated_apis)
|
||||
return "--experimental-websocket-port been deprecated, use --bind=ws:...";
|
||||
|
||||
err = opt_set_u32(arg, &port);
|
||||
|
@ -1248,7 +1248,7 @@ static char *opt_disable_ip_discovery(struct lightningd *ld)
|
|||
|
||||
static char *opt_set_announce_dns(const char *optarg, struct lightningd *ld)
|
||||
{
|
||||
if (!deprecated_apis)
|
||||
if (!ld->deprecated_apis)
|
||||
return "--announce-addr-dns has been deprecated, use --bind-addr=dns:...";
|
||||
return opt_set_bool_arg(optarg, &ld->announce_dns);
|
||||
}
|
||||
|
@ -1260,6 +1260,12 @@ static void register_opts(struct lightningd *ld)
|
|||
test_subdaemons_and_exit,
|
||||
ld,
|
||||
"Test that subdaemons can be run, then exit immediately");
|
||||
/* We need to know this even before we talk to plugins */
|
||||
clnopt_witharg("--allow-deprecated-apis",
|
||||
OPT_EARLY|OPT_SHOWBOOL,
|
||||
opt_set_bool_arg, opt_show_bool,
|
||||
&ld->deprecated_apis,
|
||||
"Enable deprecated options, JSONRPC commands, fields, etc.");
|
||||
/* Register plugins as an early args, so we can initialize them and have
|
||||
* them register more command line options */
|
||||
clnopt_witharg("--plugin", OPT_MULTI|OPT_EARLY,
|
||||
|
|
|
@ -848,7 +848,7 @@ static struct channel *find_channel_for_htlc_add(struct lightningd *ld,
|
|||
return channel;
|
||||
|
||||
/* We used to ignore scid: now all-zero means "any" */
|
||||
if (!channel && (deprecated_apis || memeqzero(scid_or_alias, sizeof(*scid_or_alias)))) {
|
||||
if (!channel && (ld->deprecated_apis || memeqzero(scid_or_alias, sizeof(*scid_or_alias)))) {
|
||||
list_for_each(&peer->channels, channel, list) {
|
||||
if (channel_can_add_htlc(channel)) {
|
||||
return channel;
|
||||
|
|
|
@ -1983,7 +1983,7 @@ static void json_add_peer(struct lightningd *ld,
|
|||
/* Note: If !PEER_CONNECTED, peer may use different features on reconnect */
|
||||
json_add_hex_talarr(response, "features", p->their_features);
|
||||
|
||||
if (deprecated_apis) {
|
||||
if (ld->deprecated_apis) {
|
||||
json_array_start(response, "channels");
|
||||
json_add_uncommitted_channel(response, p->uncommitted_channel, NULL);
|
||||
|
||||
|
|
|
@ -1014,7 +1014,7 @@ static bool htlc_accepted_hook_deserialize(struct htlc_accepted_hook_payload *re
|
|||
buffer + failmsgtok->start);
|
||||
local_fail_in_htlc(hin, take(failmsg));
|
||||
return false;
|
||||
} else if (deprecated_apis
|
||||
} else if (ld->deprecated_apis
|
||||
&& (failcodetok = json_get_member(buffer, toks,
|
||||
"failure_code"))) {
|
||||
unsigned int failcode;
|
||||
|
|
|
@ -823,7 +823,7 @@ struct io_plan *plugin_stdout_conn_init(struct io_conn *conn,
|
|||
static char *plugin_opt_check(struct plugin_opt *popt)
|
||||
{
|
||||
/* Warn them that this is deprecated */
|
||||
if (popt->deprecated && !deprecated_apis)
|
||||
if (popt->deprecated && !popt->plugin->plugins->ld->deprecated_apis)
|
||||
return tal_fmt(tmpctx, "deprecated option (will be removed!)");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -847,7 +847,7 @@ static char *plugin_opt_bool_check(const char *arg, struct plugin_opt *popt)
|
|||
{
|
||||
/* FIXME: For some reason, '1' and '0' were allowed here? */
|
||||
if (streq(arg, "1") || streq(arg, "0")) {
|
||||
if (!deprecated_apis)
|
||||
if (!popt->plugin->plugins->ld->deprecated_apis)
|
||||
return "boolean plugin arguments must be true or false";
|
||||
} else {
|
||||
bool v;
|
||||
|
@ -937,6 +937,7 @@ static const char *plugin_opt_add(struct plugin *plugin, const char *buffer,
|
|||
}
|
||||
|
||||
popt = tal(plugin, struct plugin_opt);
|
||||
popt->plugin = plugin;
|
||||
popt->name = tal_fmt(popt, "--%s",
|
||||
json_strdup(tmpctx, buffer, nametok));
|
||||
name = popt->name + 2;
|
||||
|
@ -981,7 +982,7 @@ static const char *plugin_opt_add(struct plugin *plugin, const char *buffer,
|
|||
/* We used to allow (ignore) anything, now make sure it's 'false' */
|
||||
if (!json_to_bool(buffer, defaulttok, &val)
|
||||
|| val != false) {
|
||||
if (!deprecated_apis)
|
||||
if (!plugin->plugins->ld->deprecated_apis)
|
||||
return tal_fmt(plugin, "%s type flag default must be 'false' not %.*s",
|
||||
popt->name,
|
||||
json_tok_full_len(defaulttok),
|
||||
|
@ -1624,12 +1625,13 @@ static const char *plugin_parse_getmanifest_response(const char *buffer,
|
|||
"Invalid nonnumericids: %.*s",
|
||||
json_tok_full_len(tok),
|
||||
json_tok_full(buffer, tok));
|
||||
if (!deprecated_apis && !plugin->non_numeric_ids)
|
||||
if (!plugin->plugins->ld->deprecated_apis
|
||||
&& !plugin->non_numeric_ids)
|
||||
return tal_fmt(plugin,
|
||||
"Plugin does not allow nonnumericids");
|
||||
} else
|
||||
/* Default is false in deprecated mode */
|
||||
plugin->non_numeric_ids = !deprecated_apis;
|
||||
plugin->non_numeric_ids = !plugin->plugins->ld->deprecated_apis;
|
||||
|
||||
err = plugin_notifications_add(buffer, resulttok, plugin);
|
||||
if (!err)
|
||||
|
@ -1837,7 +1839,8 @@ const char *plugin_send_getmanifest(struct plugin *p, const char *cmd_id)
|
|||
p->stdin_conn = io_new_conn(p, stdinfd, plugin_stdin_conn_init, p);
|
||||
req = jsonrpc_request_start(p, "getmanifest", cmd_id, p->non_numeric_ids,
|
||||
p->log, NULL, plugin_manifest_cb, p);
|
||||
json_add_bool(req->stream, "allow-deprecated-apis", deprecated_apis);
|
||||
json_add_bool(req->stream, "allow-deprecated-apis",
|
||||
p->plugins->ld->deprecated_apis);
|
||||
jsonrpc_request_end(req);
|
||||
plugin_request_send(p, req);
|
||||
p->plugin_state = AWAITING_GETMANIFEST_RESPONSE;
|
||||
|
@ -2204,7 +2207,7 @@ void json_add_opt_plugins_array(struct json_stream *response,
|
|||
|
||||
if (!list_empty(&p->plugin_opts)) {
|
||||
json_add_plugin_options(response, "options", p,
|
||||
!deprecated_apis);
|
||||
!plugins->ld->deprecated_apis);
|
||||
}
|
||||
json_object_end(response);
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ struct plugins {
|
|||
* command line and passing them off to the plugin
|
||||
*/
|
||||
struct plugin_opt {
|
||||
struct plugin *plugin;
|
||||
/* off plugin->plugin_opts */
|
||||
struct list_node list;
|
||||
/* includes -- prefix! */
|
||||
|
|
|
@ -191,8 +191,6 @@ void db_commit_transaction(struct db *db UNNEEDED)
|
|||
/* Generated stub for delete_channel */
|
||||
void delete_channel(struct channel *channel STEALS UNNEEDED)
|
||||
{ fprintf(stderr, "delete_channel called!\n"); abort(); }
|
||||
/* Generated stub for deprecated_apis */
|
||||
bool deprecated_apis;
|
||||
/* Generated stub for encode_scriptpubkey_to_addr */
|
||||
char *encode_scriptpubkey_to_addr(const tal_t *ctx UNNEEDED,
|
||||
const struct chainparams *chainparams UNNEEDED,
|
||||
|
|
|
@ -16,8 +16,6 @@ void db_commit_transaction(struct db *db UNNEEDED)
|
|||
/* Generated stub for delayed_to_us_feerate */
|
||||
u32 delayed_to_us_feerate(struct chain_topology *topo UNNEEDED)
|
||||
{ fprintf(stderr, "delayed_to_us_feerate called!\n"); abort(); }
|
||||
/* Generated stub for deprecated_apis */
|
||||
bool deprecated_apis;
|
||||
/* Generated stub for fatal */
|
||||
void fatal(const char *fmt UNNEEDED, ...)
|
||||
{ fprintf(stderr, "fatal called!\n"); abort(); }
|
||||
|
|
|
@ -500,6 +500,11 @@ bool command_usage_only(const struct command *cmd)
|
|||
return cmd->usage_only;
|
||||
}
|
||||
|
||||
bool command_deprecated_apis(const struct command *cmd)
|
||||
{
|
||||
return deprecated_apis;
|
||||
}
|
||||
|
||||
/* FIXME: would be good to support this! */
|
||||
bool command_check_only(const struct command *cmd)
|
||||
{
|
||||
|
|
|
@ -133,8 +133,6 @@ struct onionreply *create_onionreply(const tal_t *ctx UNNEEDED,
|
|||
const struct secret *shared_secret UNNEEDED,
|
||||
const u8 *failure_msg UNNEEDED)
|
||||
{ fprintf(stderr, "create_onionreply called!\n"); abort(); }
|
||||
/* Generated stub for deprecated_apis */
|
||||
bool deprecated_apis;
|
||||
/* Generated stub for derive_channel_id */
|
||||
void derive_channel_id(struct channel_id *channel_id UNNEEDED,
|
||||
const struct bitcoin_outpoint *outpoint UNNEEDED)
|
||||
|
|
|
@ -93,7 +93,8 @@ static struct command_result *param_newaddr(struct command *cmd,
|
|||
enum addrtype **addrtype)
|
||||
{
|
||||
*addrtype = tal(cmd, enum addrtype);
|
||||
if (deprecated_apis && json_tok_streq(buffer, tok, "p2sh-segwit"))
|
||||
if (cmd->ld->deprecated_apis
|
||||
&& json_tok_streq(buffer, tok, "p2sh-segwit"))
|
||||
**addrtype = ADDR_P2SH_SEGWIT;
|
||||
else if (json_tok_streq(buffer, tok, "bech32"))
|
||||
**addrtype = ADDR_BECH32;
|
||||
|
@ -133,7 +134,7 @@ static struct command_result *json_newaddr(struct command *cmd,
|
|||
b32script = scriptpubkey_p2wpkh(tmpctx, &pubkey);
|
||||
if (*addrtype & ADDR_BECH32)
|
||||
txfilter_add_scriptpubkey(cmd->ld->owned_txfilter, b32script);
|
||||
if (deprecated_apis && (*addrtype & ADDR_P2SH_SEGWIT))
|
||||
if (cmd->ld->deprecated_apis && (*addrtype & ADDR_P2SH_SEGWIT))
|
||||
txfilter_add_scriptpubkey(cmd->ld->owned_txfilter,
|
||||
scriptpubkey_p2sh(tmpctx, b32script));
|
||||
|
||||
|
@ -147,7 +148,7 @@ static struct command_result *json_newaddr(struct command *cmd,
|
|||
response = json_stream_success(cmd);
|
||||
if (*addrtype & ADDR_BECH32)
|
||||
json_add_string(response, "bech32", bech32);
|
||||
if (deprecated_apis && (*addrtype & ADDR_P2SH_SEGWIT))
|
||||
if (cmd->ld->deprecated_apis && (*addrtype & ADDR_P2SH_SEGWIT))
|
||||
json_add_string(response, "p2sh-segwit", p2sh);
|
||||
return command_success(cmd, response);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue