jsonrpc: use tal destructor to remove json commands when required.

This fixes a bug with a plugin duplicating an existing name
where we'd crash, too.

This doesn't work for builtins, which aren't tal objects, so
create a separate path for them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-02-04 21:25:42 +10:30
parent da355284de
commit cc76416447
3 changed files with 24 additions and 26 deletions

View File

@@ -168,17 +168,11 @@ void jsonrpc_listen(struct jsonrpc *rpc, struct lightningd *ld);
*
* Returns true if the command was added correctly, false if adding
* this would clobber a command name.
*
* Free @command to remove it.
*/
bool jsonrpc_command_add(struct jsonrpc *rpc, struct json_command *command);
/**
* Remove a command/method from the JSON-RPC.
*
* Used to dynamically remove a `struct json_command` from the
* JSON-RPC dispatch table by its name.
*/
void jsonrpc_command_remove(struct jsonrpc *rpc, const char *method);
/**
* Begin a JSON-RPC notification with the specified topic.
*