Skip to content

Commit aa45e73

Browse files
cdeckerrustyrussell
authored andcommitted
libplugin: Add parser for channel_hint from JSON
1 parent 6a53cf2 commit aa45e73

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

plugins/libplugin-pay.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,30 @@ static void channel_hint_to_json(const char *name, const struct channel_hint *hi
398398
}
399399

400400
/**
401-
* Notify subscribers of the `channel_hint` topic about a changed hint
401+
* Load a channel_hint from its JSON representation.
402402
*
403-
* We share the channel_hints across payments, and across plugins, in order to
404-
* maximize the context they have when performing payments.
403+
* @return The initialized `channel_hint` or `NULL` if we encountered a parsing
404+
* error.
405405
*/
406+
/*
407+
static struct channel_hint *channel_hint_from_json(const tal_t *ctx,
408+
const char *buffer,
409+
const jsmntok_t *toks)
410+
{
411+
const char *ret;
412+
struct channel_hint *hint = tal(ctx, struct channel_hint);
413+
ret = json_scan(ctx, buffer, toks,
414+
"{timestamp:%,scid:%,capacity_msat:%,enabled:%}",
415+
JSON_SCAN(json_to_u32, &hint->timestamp),
416+
JSON_SCAN(json_to_short_channel_id_dir, &hint->scid),
417+
JSON_SCAN(json_to_msat, &hint->estimated_capacity),
418+
JSON_SCAN(json_to_bool, &hint->enabled));
419+
420+
if (ret != NULL)
421+
hint = tal_free(hint);
422+
return hint;
423+
}
424+
*/
406425
/**
407426
* Notify subscribers of the `channel_hint` topic about a changed hint
408427
*

0 commit comments

Comments
 (0)