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

Function json_waitanyinvoice

lightningd/invoice.c:1489–1527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1487AUTODATA(json_command, &delinvoice_command);
1488
1489static struct command_result *json_waitanyinvoice(struct command *cmd,
1490 const char *buffer,
1491 const jsmntok_t *obj UNNEEDED,
1492 const jsmntok_t *params)
1493{
1494 u64 *pay_index;
1495 u64 *timeout;
1496 struct wallet *wallet = cmd->ld->wallet;
1497
1498 if (!param(cmd, buffer, params,
1499 p_opt_def("lastpay_index", param_u64, &pay_index, 0),
1500 p_opt("timeout", &param_u64, &timeout),
1501 NULL))
1502 return command_param_failed();
1503
1504 /*~ We allocate the timeout and the wallet-waitanyinvoice
1505 * in the cmd context, so whichever one manages to complete
1506 * the command first (and destroy the cmd context)
1507 * auto-cancels the other, is not tal amazing?
1508 */
1509 if (timeout)
1510 (void) new_reltimer(cmd->ld->timers, cmd,
1511 time_from_sec(*timeout),
1512 &wait_timed_out, cmd);
1513
1514 /* Set command as pending. We do not know if
1515 * wallet_invoice_waitany will return immediately
1516 * or not, so indicating pending is safest. */
1517 fixme_ignore(command_still_pending(cmd));
1518
1519 /* Find next paid invoice. */
1520 invoices_waitany(cmd, wallet->invoices, *pay_index,
1521 &wait_on_invoice, (void*) cmd);
1522
1523 return command_its_complicated("wallet_invoice_waitany might complete"
1524 " immediately, but we also call it as a"
1525 " callback so plumbing through the return"
1526 " is non-trivial.");
1527}
1528
1529
1530static const struct json_command waitanyinvoice_command = {

Callers

nothing calls this directly

Calls 7

time_from_secFunction · 0.85
fixme_ignoreFunction · 0.85
command_param_failedFunction · 0.70
command_still_pendingFunction · 0.70
command_its_complicatedFunction · 0.70
paramFunction · 0.50
invoices_waitanyFunction · 0.50

Tested by

no test coverage detected