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

Function param_route_hops

lightningd/pay.c:1417–1469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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