json: reverse parse a coin_mvt tag back into an enum

This commit is contained in:
niftynei
2022-02-16 15:36:47 -06:00
committed by Rusty Russell
parent 590f12145b
commit 7add7ca199
7 changed files with 28 additions and 2 deletions

View File

@@ -108,6 +108,22 @@ bool json_to_channel_id(const char *buffer, const jsmntok_t *tok,
cid, sizeof(*cid));
}
bool json_to_coin_mvt_tag(const char *buffer, const jsmntok_t *tok,
enum mvt_tag *tag)
{
enum mvt_tag i_tag;
for (size_t i = 0; i < NUM_MVT_TAGS; i++) {
i_tag = (enum mvt_tag) i;
if (json_tok_streq(buffer, tok, mvt_tag_str(i_tag))) {
*tag = i_tag;
return true;
}
}
return false;
}
bool split_tok(const char *buffer, const jsmntok_t *tok,
char split,
jsmntok_t *a,