| 33 | } |
| 34 | |
| 35 | struct route *tal_route_from_json(const tal_t *ctx, const char *buf, |
| 36 | const jsmntok_t *obj) |
| 37 | { |
| 38 | struct route *route = tal(ctx, struct route); |
| 39 | |
| 40 | const jsmntok_t *hashtok = json_get_member(buf, obj, "payment_hash"); |
| 41 | const jsmntok_t *groupidtok = json_get_member(buf, obj, "groupid"); |
| 42 | const jsmntok_t *partidtok = json_get_member(buf, obj, "partid"); |
| 43 | const jsmntok_t *amttok = json_get_member(buf, obj, "amount_msat"); |
| 44 | const jsmntok_t *senttok = |
| 45 | json_get_member(buf, obj, "amount_sent_msat"); |
| 46 | |
| 47 | if (hashtok == NULL || groupidtok == NULL || amttok == NULL || |
| 48 | senttok == NULL) |
| 49 | goto fail; |
| 50 | |
| 51 | if (!json_to_u64(buf, groupidtok, &route->key.groupid)) |
| 52 | goto fail; |
| 53 | if (!json_to_sha256(buf, hashtok, &route->key.payment_hash)) |
| 54 | goto fail; |
| 55 | if (!json_to_msat(buf, amttok, &route->amount_deliver)) |
| 56 | goto fail; |
| 57 | if (!json_to_msat(buf, senttok, &route->amount_sent)) |
| 58 | goto fail; |
| 59 | if (partidtok == NULL) |
| 60 | route->key.partid = 0; |
| 61 | else if (!json_to_u64(buf, partidtok, &route->key.partid)) |
| 62 | goto fail; |
| 63 | |
| 64 | route->success_prob = 0; |
| 65 | route->result = NULL; |
| 66 | route->hops = NULL; |
| 67 | route->final_msg = NULL; |
| 68 | route->final_error = LIGHTNINGD; |
| 69 | route->shared_secrets = NULL; |
| 70 | |
| 71 | return route; |
| 72 | fail: |
| 73 | |
| 74 | return tal_free(route); |
| 75 | } |
| 76 | |
| 77 | static bool get_data_details_onionreply(struct payment_result *result, |
| 78 | const char *buffer, |
no test coverage detected