MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_to_createonion_response

Function json_to_createonion_response

plugins/libplugin.c:2593–2623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2591}
2592
2593struct 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
2621fail:
2622 return tal_free(resp);
2623}
2624
2625static bool json_to_route_hop_inplace(struct route_hop *dst, const char *buffer,
2626 const jsmntok_t *toks)

Callers 1

Calls 4

json_get_memberFunction · 0.85
json_to_secretFunction · 0.85
tal_freeFunction · 0.85
json_tok_bin_from_hexFunction · 0.50

Tested by

no test coverage detected