| 2591 | } |
| 2592 | |
| 2593 | struct createonion_response *json_to_createonion_response(const tal_t *ctx, |
| 2594 | const char *buffer, |
| 2595 | const jsmntok_t *toks) |
| 2596 | { |
| 2597 | size_t i; |
| 2598 | struct createonion_response *resp; |
| 2599 | const jsmntok_t *oniontok = json_get_member(buffer, toks, "onion"); |
| 2600 | const jsmntok_t *secretstok = json_get_member(buffer, toks, "shared_secrets"); |
| 2601 | const jsmntok_t *cursectok; |
| 2602 | |
| 2603 | if (oniontok == NULL || secretstok == NULL) |
| 2604 | return NULL; |
| 2605 | |
| 2606 | resp = tal(ctx, struct createonion_response); |
| 2607 | |
| 2608 | if (oniontok->type != JSMN_STRING) |
| 2609 | goto fail; |
| 2610 | |
| 2611 | resp->onion = json_tok_bin_from_hex(resp, buffer, oniontok); |
| 2612 | resp->shared_secrets = tal_arr(resp, struct secret, secretstok->size); |
| 2613 | |
| 2614 | json_for_each_arr(i, cursectok, secretstok) { |
| 2615 | if (cursectok->type != JSMN_STRING) |
| 2616 | goto fail; |
| 2617 | json_to_secret(buffer, cursectok, &resp->shared_secrets[i]); |
| 2618 | } |
| 2619 | return resp; |
| 2620 | |
| 2621 | fail: |
| 2622 | return tal_free(resp); |
| 2623 | } |
| 2624 | |
| 2625 | static bool json_to_route_hop_inplace(struct route_hop *dst, const char *buffer, |
| 2626 | const jsmntok_t *toks) |
no test coverage detected