libplugin: Add primitive to serialize channel_hint to JSON
This commit is contained in:
committed by
Rusty Russell
parent
eae378c9d2
commit
6a53cf288b
@@ -387,6 +387,16 @@ void payment_start(struct payment *p)
|
||||
payment_start_at_blockheight(p, INVALID_BLOCKHEIGHT);
|
||||
}
|
||||
|
||||
static void channel_hint_to_json(const char *name, const struct channel_hint *hint, struct json_stream *dest)
|
||||
{
|
||||
json_object_start(dest, name);
|
||||
json_add_u32(dest, "timestamp", hint->timestamp);
|
||||
json_add_short_channel_id_dir(dest, "scid", hint->scid);
|
||||
json_add_amount_msat(dest, "capacity_msat", hint->estimated_capacity);
|
||||
json_add_bool(dest, "enabled", hint->enabled);
|
||||
json_object_end(dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify subscribers of the `channel_hint` topic about a changed hint
|
||||
*
|
||||
@@ -406,7 +416,7 @@ static void channel_hint_notify(struct plugin *plugin,
|
||||
plugin_notification_start(plugin, "channel_hint_update");
|
||||
|
||||
/* The timestamp used to decay the observation over time. */
|
||||
json_add_u32(js, "timestamp", hint->timestamp);
|
||||
channel_hint_to_json("channel_hint", hint, js);
|
||||
plugin_notification_end(plugin, js);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ void json_add_amount_msat(struct json_stream *result UNNEEDED,
|
||||
struct amount_msat msat)
|
||||
|
||||
{ fprintf(stderr, "json_add_amount_msat called!\n"); abort(); }
|
||||
/* Generated stub for json_add_bool */
|
||||
void json_add_bool(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
bool value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_bool called!\n"); abort(); }
|
||||
/* Generated stub for json_add_hex_talarr */
|
||||
void json_add_hex_talarr(struct json_stream *result UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
@@ -116,6 +120,11 @@ void json_add_short_channel_id(struct json_stream *response UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
struct short_channel_id id UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_short_channel_id called!\n"); abort(); }
|
||||
/* Generated stub for json_add_short_channel_id_dir */
|
||||
void json_add_short_channel_id_dir(struct json_stream *response UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
struct short_channel_id_dir idd UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_short_channel_id_dir called!\n"); abort(); }
|
||||
/* Generated stub for json_add_string */
|
||||
void json_add_string(struct json_stream *js UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
|
||||
@@ -78,6 +78,10 @@ void json_add_amount_msat(struct json_stream *result UNNEEDED,
|
||||
struct amount_msat msat)
|
||||
|
||||
{ fprintf(stderr, "json_add_amount_msat called!\n"); abort(); }
|
||||
/* Generated stub for json_add_bool */
|
||||
void json_add_bool(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
bool value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_bool called!\n"); abort(); }
|
||||
/* Generated stub for json_add_hex_talarr */
|
||||
void json_add_hex_talarr(struct json_stream *result UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
@@ -113,6 +117,11 @@ void json_add_short_channel_id(struct json_stream *response UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
struct short_channel_id id UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_short_channel_id called!\n"); abort(); }
|
||||
/* Generated stub for json_add_short_channel_id_dir */
|
||||
void json_add_short_channel_id_dir(struct json_stream *response UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
struct short_channel_id_dir idd UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_short_channel_id_dir called!\n"); abort(); }
|
||||
/* Generated stub for json_add_string */
|
||||
void json_add_string(struct json_stream *js UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
|
||||
Reference in New Issue
Block a user