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