From 29031c02cac4173e5aaf30f5926a1722de5b55a7 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 22 Feb 2023 14:00:49 +0100 Subject: [PATCH] libplugin: Expose the `jsonrpc_request_sync` method This one was mostly used in libplugin, but not available outside. It is rather useful, so let's expose it. --- plugins/libplugin.c | 8 ++++++++ plugins/libplugin.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/plugins/libplugin.c b/plugins/libplugin.c index 5e25535c8..3f607e89e 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -583,6 +583,14 @@ static const jsmntok_t *sync_req(const tal_t *ctx, return contents; } +const jsmntok_t *jsonrpc_request_sync(const tal_t *ctx, struct plugin *plugin, + const char *method, + const struct json_out *params TAKES, + const char **resp) +{ + return sync_req(ctx, plugin, method, params, resp); +} + /* Returns contents of scanning guide on 'result' */ static const char *rpc_scan_core(const tal_t *ctx, struct plugin *plugin, diff --git a/plugins/libplugin.h b/plugins/libplugin.h index ac3313d3e..1c09a7800 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -478,4 +478,11 @@ void plugin_set_memleak_handler(struct plugin *plugin, struct htable *memtable)); #endif /* DEVELOPER */ +/* Synchronously call a JSON-RPC method and return its contents and + * the parser token. */ +const jsmntok_t *jsonrpc_request_sync(const tal_t *ctx, struct plugin *plugin, + const char *method, + const struct json_out *params TAKES, + const char **resp); + #endif /* LIGHTNING_PLUGINS_LIBPLUGIN_H */