Skip to content

Commit

Permalink
jsonrpc: add jsonrpc_command_del
Browse files Browse the repository at this point in the history
usefull for removing plugin's method without killing it
  • Loading branch information
SimonVrouwe committed Sep 29, 2021
1 parent ce95fd7 commit ee5dbc0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lightningd/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,18 @@ bool jsonrpc_command_add(struct jsonrpc *rpc, struct json_command *command,
return true;
}

bool jsonrpc_command_del(struct jsonrpc *rpc, const char *name)
{
size_t count = tal_count(rpc->commands);
for (size_t j = 0; j < count; j++) {
if (streq(name, rpc->commands[j]->name)) {
tal_free(rpc->commands[j]);
return true;
}
}
return false;
}

static bool jsonrpc_command_add_perm(struct lightningd *ld,
struct jsonrpc *rpc,
struct json_command *command)
Expand Down
3 changes: 3 additions & 0 deletions lightningd/jsonrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ void jsonrpc_listen(struct jsonrpc *rpc, struct lightningd *ld);
bool jsonrpc_command_add(struct jsonrpc *rpc, struct json_command *command,
const char *usage TAKES);

/* Remove a command from the JSON-RPC interface */
bool jsonrpc_command_del(struct jsonrpc *rpc, const char *name);

/**
* Begin a JSON-RPC notification with the specified topic.
*
Expand Down

0 comments on commit ee5dbc0

Please sign in to comment.