| 1274 | } |
| 1275 | |
| 1276 | static struct command_result *json_sendonion(struct command *cmd, |
| 1277 | const char *buffer, |
| 1278 | const jsmntok_t *obj UNNEEDED, |
| 1279 | const jsmntok_t *params) |
| 1280 | { |
| 1281 | u8 *onion; |
| 1282 | struct onionpacket *packet; |
| 1283 | enum onion_wire failcode; |
| 1284 | struct route_hop *first_hop; |
| 1285 | struct sha256 *payment_hash; |
| 1286 | struct lightningd *ld = cmd->ld; |
| 1287 | const char *label, *invstring, *description; |
| 1288 | struct node_id *destination; |
| 1289 | struct secret *path_secrets; |
| 1290 | struct amount_msat *msat; |
| 1291 | u64 *partid, *group; |
| 1292 | struct sha256 *local_offer_id = NULL; |
| 1293 | |
| 1294 | if (!param(cmd, buffer, params, |
| 1295 | p_req("onion", param_bin_from_hex, &onion), |
| 1296 | p_req("first_hop", param_route_hop, &first_hop), |
| 1297 | p_req("payment_hash", param_sha256, &payment_hash), |
| 1298 | p_opt("label", param_escaped_string, &label), |
| 1299 | p_opt("shared_secrets", param_secrets_array, &path_secrets), |
| 1300 | p_opt_def("partid", param_u64, &partid, 0), |
| 1301 | /* FIXME: parameter should be invstring now */ |
| 1302 | p_opt("bolt11", param_string, &invstring), |
| 1303 | p_opt_def("amount_msat|msatoshi", param_msat, &msat, AMOUNT_MSAT(0)), |
| 1304 | p_opt("destination", param_node_id, &destination), |
| 1305 | p_opt("localofferid", param_sha256, &local_offer_id), |
| 1306 | p_opt("groupid", param_u64, &group), |
| 1307 | p_opt("description", param_string, &description), |
| 1308 | NULL)) |
| 1309 | return command_param_failed(); |
| 1310 | |
| 1311 | /* If groupid was not provided default to incrementing from the previous one. */ |
| 1312 | if (group == NULL) { |
| 1313 | group = tal(tmpctx, u64); |
| 1314 | *group = |
| 1315 | wallet_payment_get_groupid(cmd->ld->wallet, payment_hash) + |
| 1316 | 1; |
| 1317 | } |
| 1318 | |
| 1319 | packet = parse_onionpacket(cmd, onion, tal_bytelen(onion), &failcode); |
| 1320 | |
| 1321 | if (!packet) |
| 1322 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 1323 | "Could not parse the onion. Parsing failed " |
| 1324 | "with failcode=%d", |
| 1325 | failcode); |
| 1326 | |
| 1327 | return send_payment_core(ld, cmd, payment_hash, *partid, *group, |
| 1328 | first_hop, *msat, AMOUNT_MSAT(0), |
| 1329 | label, invstring, description, |
| 1330 | packet, destination, NULL, NULL, |
| 1331 | path_secrets, local_offer_id); |
| 1332 | } |
| 1333 |
nothing calls this directly
no test coverage detected