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

Function json_add_blinded_paths

plugins/offers.c:249–282  ·  view source on GitHub ↗

Returns true if valid */

Source from the content-addressed store, hash-verified

247
248/* Returns true if valid */
249static bool json_add_blinded_paths(struct json_stream *js,
250 struct blinded_path **paths,
251 struct blinded_payinfo **blindedpay)
252{
253 size_t n = 0;
254 json_array_start(js, "paths");
255 for (size_t i = 0; i < tal_count(paths); i++) {
256 json_object_start(js, NULL);
257 json_add_pubkey(js, "blinding", &paths[i]->blinding);
258 json_array_start(js, "path");
259 for (size_t j = 0; j < tal_count(paths[i]->path); j++) {
260 json_add_onionmsg_path(js, NULL, paths[i]->path[j],
261 n < tal_count(blindedpay)
262 ? blindedpay[n] : NULL);
263 n++;
264 }
265 json_array_end(js);
266 json_object_end(js);
267 }
268 json_array_end(js);
269
270 /* BOLT-offers #12:
271 * - MUST reject the invoice if `blinded_payinfo` does not contain
272 * exactly as many `payinfo` as total `onionmsg_path` in
273 * `blinded_path`.
274 */
275 if (blindedpay && n != tal_count(blindedpay)) {
276 json_add_string(js, "warning_invoice_invalid_blinded_payinfo",
277 "invoice does not have correct number of blinded_payinfo");
278 return false;
279 }
280
281 return true;
282}
283
284static const char *recurrence_time_unit_name(u8 time_unit)
285{

Callers 2

json_add_offerFunction · 0.85
json_add_b12_invoiceFunction · 0.85

Calls 7

json_add_pubkeyFunction · 0.85
json_add_onionmsg_pathFunction · 0.85
json_array_startFunction · 0.50
json_object_startFunction · 0.50
json_array_endFunction · 0.50
json_object_endFunction · 0.50
json_add_stringFunction · 0.50

Tested by

no test coverage detected