Files
palladum-lightning/common/json_blinded_path.c
Rusty Russell 6e5cb299dd global: remove unnecessary includes from C files.
Basically, `devtools/reduce-includes.sh */*.c`.

Build time from make clean (RUST=0) (includes building external libs):

Before:
	real    0m38.944000-40.416000(40.1131+/-0.4)s
	user    3m6.790000-17.159000(15.0571+/-2.8)s
	sys     0m35.304000-37.336000(36.8942+/-0.57)s
After:
	real    0m37.872000-39.974000(39.5466+/-0.59)s
	user    3m1.211000-14.968000(12.4556+/-3.9)s
	sys     0m35.008000-36.830000(36.4143+/-0.5)s

Build time after touch config.vars (RUST=0):

Before:
	real    0m19.831000-21.862000(21.5528+/-0.58)s
	user    2m15.361000-30.731000(28.4798+/-4.4)s
	sys     0m21.056000-22.339000(22.0346+/-0.35)s

After:
	real    0m18.384000-21.307000(20.8605+/-0.92)s
	user    2m5.585000-26.843000(23.6017+/-6.7)s
	sys     0m19.650000-22.003000(21.4943+/-0.69)s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-10-23 06:44:04 +10:30

59 lines
1.7 KiB
C

#include "config.h"
#include <common/json_blinded_path.h>
#include <common/json_parse.h>
#include <common/utils.h>
#include <wire/onion_wiregen.h>
struct blinded_path *
json_to_blinded_path(const tal_t *ctx, const char *buffer, const jsmntok_t *tok)
{
struct blinded_path *rpath;
const jsmntok_t *hops, *t;
size_t i;
const char *err;
struct pubkey first_node_id;
struct short_channel_id_dir first_scidd;
rpath = tal(ctx, struct blinded_path);
/* It will give us either scid or node_id */
memset(&first_scidd, 0, sizeof(first_scidd));
err = json_scan(tmpctx, buffer, tok,
"{first_path_key:%,"
"first_node_id?:%,"
"first_scid?:%,"
"first_scid_dir?:%}",
JSON_SCAN(json_to_pubkey, &rpath->first_path_key),
JSON_SCAN(json_to_pubkey, &first_node_id),
JSON_SCAN(json_to_short_channel_id, &first_scidd.scid),
JSON_SCAN(json_to_int, &first_scidd.dir),
NULL);
if (err)
return tal_free(rpath);
if (first_scidd.scid.u64 != 0)
sciddir_or_pubkey_from_scidd(&rpath->first_node_id, &first_scidd);
else
sciddir_or_pubkey_from_pubkey(&rpath->first_node_id, &first_node_id);
hops = json_get_member(buffer, tok, "hops");
if (!hops || hops->size < 1)
return tal_free(rpath);
rpath->path = tal_arr(rpath, struct blinded_path_hop *, hops->size);
json_for_each_arr(i, t, hops) {
rpath->path[i] = tal(rpath->path, struct blinded_path_hop);
err = json_scan(tmpctx, buffer, t, "{blinded_node_id:%,encrypted_recipient_data:%}",
JSON_SCAN(json_to_pubkey,
&rpath->path[i]->blinded_node_id),
JSON_SCAN_TAL(rpath->path[i],
json_tok_bin_from_hex,
&rpath->path[i]->encrypted_recipient_data));
if (err)
return tal_free(rpath);
}
return rpath;
}