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

Function onion_message_serialize

lightningd/onion_message.c:46–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

json_add_pubkeyFunction · 0.85
json_add_blindedpathFunction · 0.85
json_add_hexFunction · 0.85
json_object_startFunction · 0.50
json_add_hex_talarrFunction · 0.50
json_array_startFunction · 0.50
json_add_u64Function · 0.50
json_object_endFunction · 0.50
json_array_endFunction · 0.50

Tested by

no test coverage detected