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

Function json_to_createonion_response

plugins/libplugin.c:2583–2613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2581}
2582
2583struct 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
2611fail:
2612 return tal_free(resp);
2613}
2614
2615static bool json_to_route_hop_inplace(struct route_hop *dst, const char *buffer,
2616 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