mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
lightningd: derive JSONRPC ids from incoming id (append /cln:<method>#NNN).
Usually the calls are spontanous, so it's just "cln:<method>#NNN", but json_invoice() calls listincoming, and json_checkmessage calls listnodes, so those become "cli:invoice-<pid>/cln:listincoming#NNN". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1314,7 +1314,8 @@ void jsonrpc_notification_end(struct jsonrpc_notification *n)
|
||||
}
|
||||
|
||||
struct jsonrpc_request *jsonrpc_request_start_(
|
||||
const tal_t *ctx, const char *method, struct log *log,
|
||||
const tal_t *ctx, const char *method,
|
||||
const char *id_prefix, struct log *log,
|
||||
bool add_header,
|
||||
void (*notify_cb)(const char *buffer,
|
||||
const jsmntok_t *methodtok,
|
||||
@@ -1327,7 +1328,11 @@ struct jsonrpc_request *jsonrpc_request_start_(
|
||||
{
|
||||
struct jsonrpc_request *r = tal(ctx, struct jsonrpc_request);
|
||||
static u64 next_request_id = 0;
|
||||
r->id = tal_fmt(r, "cln:%s#%"PRIu64, method, next_request_id);
|
||||
if (id_prefix)
|
||||
r->id = tal_fmt(r, "%s/cln:%s#%"PRIu64,
|
||||
id_prefix, method, next_request_id);
|
||||
else
|
||||
r->id = tal_fmt(r, "cln:%s#%"PRIu64, method, next_request_id);
|
||||
next_request_id++;
|
||||
r->notify_cb = notify_cb;
|
||||
r->response_cb = response_cb;
|
||||
|
||||
Reference in New Issue
Block a user