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

Function param_route_hops

lightningd/pay.c:1414–1466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1412}
1413
1414static struct command_result *param_route_hops(struct command *cmd,
1415 const char *name,
1416 const char *buffer,
1417 const jsmntok_t *tok,
1418 struct route_hop **hops)
1419{
1420 size_t i;
1421 const jsmntok_t *t;
1422
1423 if (tok->type != JSMN_ARRAY)
1424 return command_fail_badparam(cmd, name, buffer, tok, "must be an array");
1425
1426 *hops = tal_arr(cmd, struct route_hop, tok->size);
1427 json_for_each_arr(i, t, tok) {
1428 struct command_result *ret;
1429 const jsmntok_t *member;
1430 struct short_channel_id_dir scidd;
1431
1432 ret = either(cmd, name, buffer, t, "short_channel_id_dir", "channel", &member);
1433 if (ret)
1434 return ret;
1435 if (!json_to_short_channel_id_dir(buffer, member, &scidd)
1436 && !json_to_short_channel_id(buffer, member, &scidd.scid)) {
1437 return command_fail_badparam(cmd, name, buffer, member,
1438 "bad short_channel_id");
1439 }
1440 /* We don't actually need the direction */
1441 (*hops)[i].scid = scidd.scid;
1442 ret = either(cmd, name, buffer, t, "node_id_out", "id", &member);
1443 if (ret)
1444 return ret;
1445 if (!json_to_node_id(buffer, member, &(*hops)[i].node_id)) {
1446 return command_fail_badparam(cmd, name, buffer, member,
1447 "bad node_id");
1448 }
1449 ret = either(cmd, name, buffer, t, "amount_out_msat", "amount_msat", &member);
1450 if (ret)
1451 return ret;
1452 if (!json_to_msat(buffer, member, &(*hops)[i].amount)) {
1453 return command_fail_badparam(cmd, name, buffer, member,
1454 "bad amount");
1455 }
1456 ret = either(cmd, name, buffer, t, "cltv_out", "delay", &member);
1457 if (ret)
1458 return ret;
1459 if (!json_to_u32(buffer, member, &(*hops)[i].delay)) {
1460 return command_fail_badparam(cmd, name, buffer, member,
1461 "bad cltv_out/delay");
1462 }
1463 }
1464
1465 return NULL;
1466}
1467
1468/* We're paying ourselves! */
1469static struct command_result *self_payment(struct lightningd *ld,

Callers

nothing calls this directly

Calls 7

eitherFunction · 0.85
command_fail_badparamFunction · 0.50
json_to_short_channel_idFunction · 0.50
json_to_node_idFunction · 0.50
json_to_msatFunction · 0.50
json_to_u32Function · 0.50

Tested by

no test coverage detected