| 166 | } |
| 167 | |
| 168 | static 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 | |
| 201 | static const struct json_command injectonionmessage_command = { |
| 202 | "injectonionmessage", |
nothing calls this directly
no test coverage detected