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

Function onion_message_serialize

lightningd/onion_message.c:44–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44static void onion_message_serialize(struct onion_message_hook_payload *payload,
45 struct json_stream *stream,
46 struct plugin *plugin)
47{
48 json_object_start(stream, "onion_message");
49 if (payload->pathsecret)
50 json_add_secret(stream, "pathsecret", payload->pathsecret);
51
52 if (payload->reply_path)
53 json_add_blindedpath(plugin, stream, "reply_blindedpath",
54 payload->reply_path);
55
56 if (payload->om->invoice_request)
57 json_add_hex_talarr(stream, "invoice_request",
58 payload->om->invoice_request);
59 if (payload->om->invoice)
60 json_add_hex_talarr(stream, "invoice", payload->om->invoice);
61
62 if (payload->om->invoice_error)
63 json_add_hex_talarr(stream, "invoice_error",
64 payload->om->invoice_error);
65
66 json_array_start(stream, "unknown_fields");
67 for (size_t i = 0; i < tal_count(payload->om->fields); i++) {
68 if (payload->om->fields[i].meta)
69 continue;
70 json_object_start(stream, NULL);
71 json_add_u64(stream, "number", payload->om->fields[i].numtype);
72 json_add_hex(stream, "value",
73 payload->om->fields[i].value,
74 payload->om->fields[i].length);
75 json_object_end(stream);
76 }
77 json_array_end(stream);
78
79 json_object_end(stream);
80}
81
82static void
83onion_message_hook_cb(struct onion_message_hook_payload *payload STEALS)

Callers

nothing calls this directly

Calls 9

json_object_startFunction · 0.85
json_add_secretFunction · 0.85
json_add_blindedpathFunction · 0.85
json_add_hex_talarrFunction · 0.85
json_array_startFunction · 0.85
json_add_u64Function · 0.85
json_add_hexFunction · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85

Tested by

no test coverage detected