mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
commando: build ID of command based on the id they give us.
We change the libplugin API so commando can provide its own ID base. This id chaining enables much nicer diagnostics! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -365,6 +365,7 @@ static void try_command(struct node_id *peer,
|
||||
const jsmntok_t *toks, *method, *params, *rune, *id;
|
||||
const char *buf = (const char *)msg, *failmsg;
|
||||
struct out_req *req;
|
||||
const char *cmdid_prefix;
|
||||
|
||||
incoming->peer = *peer;
|
||||
incoming->id = idnum;
|
||||
@@ -395,10 +396,17 @@ static void try_command(struct node_id *peer,
|
||||
}
|
||||
rune = json_get_member(buf, toks, "rune");
|
||||
id = json_get_member(buf, toks, "id");
|
||||
if (!id && !deprecated_apis) {
|
||||
commando_error(incoming, COMMANDO_ERROR_REMOTE,
|
||||
"missing id field");
|
||||
return;
|
||||
if (!id) {
|
||||
if (!deprecated_apis) {
|
||||
commando_error(incoming, COMMANDO_ERROR_REMOTE,
|
||||
"missing id field");
|
||||
return;
|
||||
}
|
||||
cmdid_prefix = NULL;
|
||||
} else {
|
||||
cmdid_prefix = tal_fmt(tmpctx, "%.*s/",
|
||||
id->end - id->start,
|
||||
buf + id->start);
|
||||
}
|
||||
|
||||
failmsg = check_rune(tmpctx, incoming, peer, buf, method, params, rune);
|
||||
@@ -412,6 +420,7 @@ static void try_command(struct node_id *peer,
|
||||
req = jsonrpc_request_whole_object_start(plugin, NULL,
|
||||
json_strdup(tmpctx, buf,
|
||||
method),
|
||||
cmdid_prefix,
|
||||
cmd_done, incoming);
|
||||
if (params) {
|
||||
size_t i;
|
||||
|
||||
Reference in New Issue
Block a user