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

Function json_waitanyinvoice

lightningd/invoice.c:1502–1540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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