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

Function handle_onionmsg_to_us

lightningd/onion_message.c:106–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105
106void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg)
107{
108 struct onion_message_hook_payload *payload;
109 u8 *submsg;
110 size_t submsglen;
111 const u8 *subptr;
112
113 payload = tal(tmpctx, struct onion_message_hook_payload);
114 if (!fromwire_connectd_got_onionmsg_to_us(payload, msg,
115 &payload->pathsecret,
116 &payload->reply_path,
117 &submsg)) {
118 log_broken(ld->log, "bad got_onionmsg_tous: %s",
119 tal_hex(tmpctx, msg));
120 return;
121 }
122
123 if (ld->dev_ignore_modern_onion)
124 return;
125
126 submsglen = tal_bytelen(submsg);
127 subptr = submsg;
128 payload->om = fromwire_tlv_onionmsg_tlv(payload, &subptr, &submsglen);
129 if (!payload->om) {
130 log_broken(ld->log, "bad got_onionmsg_tous om: %s",
131 tal_hex(tmpctx, msg));
132 return;
133 }
134 tal_free(submsg);
135
136 /* Make sure connectd gets this right. */
137 log_debug(ld->log, "Got onionmsg%s%s",
138 payload->pathsecret ? " with pathsecret": "",
139 payload->reply_path ? " reply_path": "");
140
141 /* We'll free this on return */
142 tal_steal(ld, payload);
143 if (payload->pathsecret)
144 plugin_hook_call_onion_message_recv_secret(ld, NULL, payload);
145 else
146 plugin_hook_call_onion_message_recv(ld, NULL, payload);
147}
148
149static void inject_onionmsg_reply(struct subd *connectd,
150 const u8 *reply,

Callers 1

connectd_msgFunction · 0.85

Calls 3

tal_hexFunction · 0.85
tal_bytelenFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected