From c91483f6050209629a335bcdb069c126e889c433 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 8 Jun 2019 10:58:08 +0200 Subject: [PATCH] json: Add wrapper to add a secret to a JSON result Signed-off-by: Christian Decker --- lightningd/json.c | 6 ++++++ lightningd/json.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lightningd/json.c b/lightningd/json.c index b28012ecc..11a661d88 100644 --- a/lightningd/json.c +++ b/lightningd/json.c @@ -440,3 +440,9 @@ void json_add_time(struct json_stream *result, const char *fieldname, (unsigned)ts.tv_nsec); json_add_string(result, fieldname, timebuf); } + +void json_add_secret(struct json_stream *response, const char *fieldname, + const struct secret *secret) +{ + json_add_hex(response, fieldname, secret, sizeof(struct secret)); +} diff --git a/lightningd/json.h b/lightningd/json.h index 514a6d323..ee4c9a447 100644 --- a/lightningd/json.h +++ b/lightningd/json.h @@ -5,6 +5,7 @@ #ifndef LIGHTNING_LIGHTNINGD_JSON_H #define LIGHTNING_LIGHTNINGD_JSON_H #include "config.h" +#include #include #include #include @@ -42,6 +43,11 @@ void json_add_pubkey(struct json_stream *response, const char *fieldname, const struct pubkey *key); +/* '"fieldname" : "89abcdef..."' or "89abcdef..." if fieldname is NULL */ +void json_add_secret(struct json_stream *response, + const char *fieldname, + const struct secret *secret); + /* '"fieldname" : "0289abcdef..."' or "0289abcdef..." if fieldname is NULL */ void json_add_node_id(struct json_stream *response, const char *fieldname,