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

Function json_injectonionmessage

lightningd/onion_message.c:168–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

param_checkFunction · 0.85
feature_offeredFunction · 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

Tested by

no test coverage detected