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