MCPcopy Create free account
hub / github.com/ElementsProject/lightning / tal_routekey_from_json

Function tal_routekey_from_json

plugins/renepay/json.c:8–33  ·  view source on GitHub ↗

See if this notification is about one of our flows. */

Source from the content-addressed store, hash-verified

6
7/* See if this notification is about one of our flows. */
8struct routekey *tal_routekey_from_json(const tal_t *ctx, const char *buf,
9 const jsmntok_t *obj)
10{
11 struct routekey *key = tal(ctx, struct routekey);
12
13 const jsmntok_t *hashtok = json_get_member(buf, obj, "payment_hash");
14 const jsmntok_t *groupidtok = json_get_member(buf, obj, "groupid");
15 const jsmntok_t *partidtok = json_get_member(buf, obj, "partid");
16
17 if (hashtok == NULL || groupidtok == NULL)
18 goto fail;
19
20 if (!json_to_u64(buf, groupidtok, &key->groupid))
21 goto fail;
22 if (!json_to_sha256(buf, hashtok, &key->payment_hash))
23 goto fail;
24 if (partidtok == NULL)
25 key->partid = 0;
26 else if (!json_to_u64(buf, partidtok, &key->partid))
27 goto fail;
28
29 return key;
30fail:
31
32 return tal_free(key);
33}
34
35struct route *tal_route_from_json(const tal_t *ctx, const char *buf,
36 const jsmntok_t *obj)

Callers 2

Calls 4

json_get_memberFunction · 0.85
json_to_sha256Function · 0.85
tal_freeFunction · 0.85
json_to_u64Function · 0.50

Tested by

no test coverage detected