Skip to content

Commit 8d42e12

Browse files
committed
renepay: add function blinded path to json
Changelog-None. Signed-off-by: Lagrang3 <[email protected]>
1 parent 144f5fd commit 8d42e12

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

plugins/renepay/json.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,27 @@ void json_add_route(struct json_stream *js, const struct route *route,
327327
json_add_string(js, "description", pinfo->description);
328328

329329
}
330+
331+
void json_myadd_blinded_path(struct json_stream *s,
332+
const char *fieldname,
333+
const struct blinded_path *blinded_path)
334+
{
335+
// FIXME: how can we support the case when the entry point is a
336+
// scid?
337+
assert(blinded_path->first_node_id.is_pubkey);
338+
json_object_start(s, fieldname);
339+
json_add_pubkey(s, "first_node_id",
340+
&blinded_path->first_node_id.pubkey);
341+
json_add_pubkey(s, "first_path_key", &blinded_path->first_path_key);
342+
json_array_start(s, "path");
343+
for (size_t i = 0; i < tal_count(blinded_path->path); i++) {
344+
const struct blinded_path_hop *hop = blinded_path->path[i];
345+
json_object_start(s, NULL);
346+
json_add_pubkey(s, "blinded_node_id", &hop->blinded_node_id);
347+
json_add_hex_talarr(s, "encrypted_recipient_data",
348+
hop->encrypted_recipient_data);
349+
json_object_end(s);
350+
}
351+
json_array_end(s);
352+
json_object_end(s);
353+
}

plugins/renepay/json.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ void json_add_payment(struct json_stream *s, const struct payment *payment);
2020
void json_add_route(struct json_stream *s, const struct route *route,
2121
const struct payment *payment);
2222

23+
void json_myadd_blinded_path(struct json_stream *s,
24+
const char *fieldname,
25+
const struct blinded_path *blinded_path);
26+
2327
#endif /* LIGHTNING_PLUGINS_RENEPAY_JSON_H */

plugins/renepay/routetracker.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -372,27 +372,8 @@ struct command_result *route_sendpay_request(struct command *cmd,
372372
assert(pinfo->blinded_paths);
373373
const struct blinded_path *bpath =
374374
pinfo->blinded_paths[route->path_num];
375+
json_myadd_blinded_path(req->js, "blinded_path", bpath);
375376

376-
// FIXME: how can we support the case when the entry point is a
377-
// scid?
378-
assert(bpath->first_node_id.is_pubkey);
379-
json_object_start(req->js, "blinded_path");
380-
json_add_pubkey(req->js, "first_node_id",
381-
&bpath->first_node_id.pubkey);
382-
json_add_pubkey(req->js, "first_path_key",
383-
&bpath->first_path_key);
384-
json_array_start(req->js, "path");
385-
for (size_t i = 0; i < tal_count(bpath->path); i++) {
386-
const struct blinded_path_hop *hop = bpath->path[i];
387-
json_object_start(req->js, NULL);
388-
json_add_pubkey(req->js, "blinded_node_id",
389-
&hop->blinded_node_id);
390-
json_add_hex_talarr(req->js, "encrypted_recipient_data",
391-
hop->encrypted_recipient_data);
392-
json_object_end(req->js);
393-
}
394-
json_array_end(req->js);
395-
json_object_end(req->js);
396377
}
397378

398379
route_map_add(payment->routetracker->sent_routes, route);

0 commit comments

Comments
 (0)