| 1921 | } |
| 1922 | |
| 1923 | struct createonion_response *json_to_createonion_response(const tal_t *ctx, |
| 1924 | const char *buffer, |
| 1925 | const jsmntok_t *toks) |
| 1926 | { |
| 1927 | size_t i; |
| 1928 | struct createonion_response *resp; |
| 1929 | const jsmntok_t *oniontok = json_get_member(buffer, toks, "onion"); |
| 1930 | const jsmntok_t *secretstok = json_get_member(buffer, toks, "shared_secrets"); |
| 1931 | const jsmntok_t *cursectok; |
| 1932 | |
| 1933 | if (oniontok == NULL || secretstok == NULL) |
| 1934 | return NULL; |
| 1935 | |
| 1936 | resp = tal(ctx, struct createonion_response); |
| 1937 | |
| 1938 | if (oniontok->type != JSMN_STRING) |
| 1939 | goto fail; |
| 1940 | |
| 1941 | resp->onion = json_tok_bin_from_hex(resp, buffer, oniontok); |
| 1942 | resp->shared_secrets = tal_arr(resp, struct secret, secretstok->size); |
| 1943 | |
| 1944 | json_for_each_arr(i, cursectok, secretstok) { |
| 1945 | if (cursectok->type != JSMN_STRING) |
| 1946 | goto fail; |
| 1947 | json_to_secret(buffer, cursectok, &resp->shared_secrets[i]); |
| 1948 | } |
| 1949 | return resp; |
| 1950 | |
| 1951 | fail: |
| 1952 | return tal_free(resp); |
| 1953 | } |
| 1954 | |
| 1955 | static bool json_to_route_hop_inplace(struct route_hop *dst, const char *buffer, |
| 1956 | const jsmntok_t *toks) |
no test coverage detected