mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
libplugin: initialize deprecated in getmanifest.
We currently do it by calling listconfigs, but that may be too late. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -568,10 +568,24 @@ send_outreq(struct plugin *plugin, const struct out_req *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct command_result *
|
static struct command_result *
|
||||||
handle_getmanifest(struct command *getmanifest_cmd)
|
handle_getmanifest(struct command *getmanifest_cmd,
|
||||||
|
const char *buf,
|
||||||
|
const jsmntok_t *getmanifest_params)
|
||||||
{
|
{
|
||||||
struct json_stream *params = jsonrpc_stream_success(getmanifest_cmd);
|
struct json_stream *params = jsonrpc_stream_success(getmanifest_cmd);
|
||||||
struct plugin *p = getmanifest_cmd->plugin;
|
struct plugin *p = getmanifest_cmd->plugin;
|
||||||
|
const jsmntok_t *dep;
|
||||||
|
|
||||||
|
/* This was added post 0.9.0 */
|
||||||
|
dep = json_get_member(buf, getmanifest_params, "allow-deprecated-apis");
|
||||||
|
if (!dep)
|
||||||
|
deprecated_apis = true;
|
||||||
|
else {
|
||||||
|
if (!json_to_bool(buf, dep, &deprecated_apis))
|
||||||
|
plugin_err(p, "Invalid allow-deprecated-apis '%.*s'",
|
||||||
|
json_tok_full_len(dep),
|
||||||
|
json_tok_full(buf, dep));
|
||||||
|
}
|
||||||
|
|
||||||
json_array_start(params, "options");
|
json_array_start(params, "options");
|
||||||
for (size_t i = 0; i < tal_count(p->opts); i++) {
|
for (size_t i = 0; i < tal_count(p->opts); i++) {
|
||||||
@@ -765,7 +779,6 @@ static struct command_result *handle_init(struct command *cmd,
|
|||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
size_t i;
|
size_t i;
|
||||||
char *dir, *network;
|
char *dir, *network;
|
||||||
struct json_out *param_obj;
|
|
||||||
struct plugin *p = cmd->plugin;
|
struct plugin *p = cmd->plugin;
|
||||||
bool with_rpc = p->rpc_conn != NULL;
|
bool with_rpc = p->rpc_conn != NULL;
|
||||||
|
|
||||||
@@ -812,11 +825,6 @@ static struct command_result *handle_init(struct command *cmd,
|
|||||||
membuf_init(&p->rpc_conn->mb, tal_arr(p, char, READ_CHUNKSIZE),
|
membuf_init(&p->rpc_conn->mb, tal_arr(p, char, READ_CHUNKSIZE),
|
||||||
READ_CHUNKSIZE, membuf_tal_realloc);
|
READ_CHUNKSIZE, membuf_tal_realloc);
|
||||||
|
|
||||||
param_obj = json_out_obj(NULL, "config", "allow-deprecated-apis");
|
|
||||||
deprecated_apis =
|
|
||||||
streq(rpc_delve(tmpctx, p, "listconfigs", take(param_obj),
|
|
||||||
".allow-deprecated-apis"),
|
|
||||||
"true");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
opttok = json_get_member(buf, params, "options");
|
opttok = json_get_member(buf, params, "options");
|
||||||
@@ -1022,7 +1030,7 @@ static void ld_command_handle(struct plugin *plugin,
|
|||||||
|
|
||||||
if (!plugin->manifested) {
|
if (!plugin->manifested) {
|
||||||
if (streq(cmd->methodname, "getmanifest")) {
|
if (streq(cmd->methodname, "getmanifest")) {
|
||||||
handle_getmanifest(cmd);
|
handle_getmanifest(cmd, plugin->buffer, paramstok);
|
||||||
plugin->manifested = true;
|
plugin->manifested = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user