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

Function json_injectonionmessage

lightningd/onion_message.c:174–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174static struct command_result *json_injectonionmessage(struct command *cmd,
175 const char *buffer,
176 const jsmntok_t *obj UNNEEDED,
177 const jsmntok_t *params)
178{
179 struct pubkey *path_key;
180 u8 *msg;
181
182 if (!param_check(cmd, buffer, params,
183 p_req("path_key", param_pubkey, &path_key),
184 p_req("message", param_bin_from_hex, &msg),
185 NULL))
186 return command_param_failed();
187
188 if (!feature_offered(cmd->ld->our_features->bits[NODE_ANNOUNCE_FEATURE],
189 OPT_ONION_MESSAGES))
190 return command_fail(cmd, LIGHTNINGD,
191 "experimental-onion-messages not enabled");
192
193 if (tal_count(msg) > 65535) {
194 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
195 "onion message too long");
196 }
197
198 if (command_check_only(cmd))
199 return command_check_done(cmd);
200
201 subd_req(cmd, cmd->ld->connectd,
202 take(towire_connectd_inject_onionmsg(NULL, path_key, msg)),
203 -1, 0, inject_onionmsg_reply, cmd);
204 return command_still_pending(cmd);
205}
206
207static const struct json_command injectonionmessage_command = {
208 "injectonionmessage",

Callers

nothing calls this directly

Calls 8

param_checkFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70
subd_reqClass · 0.70
command_still_pendingFunction · 0.70
feature_offeredFunction · 0.50

Tested by

no test coverage detected