See if this notification is about one of our flows. */
| 6 | |
| 7 | /* See if this notification is about one of our flows. */ |
| 8 | struct 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; |
| 30 | fail: |
| 31 | |
| 32 | return tal_free(key); |
| 33 | } |
| 34 | |
| 35 | struct route *tal_route_from_json(const tal_t *ctx, const char *buf, |
| 36 | const jsmntok_t *obj) |
no test coverage detected