| 434 | } |
| 435 | |
| 436 | static struct command_result *json_autocleaninvoice(struct command *cmd, |
| 437 | const char *buffer, |
| 438 | const jsmntok_t *params) |
| 439 | { |
| 440 | u64 *cycle; |
| 441 | u64 *exby; |
| 442 | struct json_stream *response; |
| 443 | |
| 444 | if (!param(cmd, buffer, params, |
| 445 | p_opt_def("cycle_seconds", param_u64, &cycle, 3600), |
| 446 | p_opt_def("expired_by", param_u64, &exby, 86400), |
| 447 | NULL)) |
| 448 | return command_param_failed(); |
| 449 | |
| 450 | cleantimer = tal_free(cleantimer); |
| 451 | |
| 452 | if (*cycle == 0) { |
| 453 | timer_cinfo.subsystem_age[EXPIREDINVOICES] = 0; |
| 454 | response = jsonrpc_stream_success(cmd); |
| 455 | json_add_bool(response, "enabled", false); |
| 456 | return command_finished(cmd, response); |
| 457 | } |
| 458 | |
| 459 | cycle_seconds = *cycle; |
| 460 | timer_cinfo.subsystem_age[EXPIREDINVOICES] = *exby; |
| 461 | cleantimer = plugin_timer(cmd->plugin, time_from_sec(cycle_seconds), |
| 462 | do_clean_timer, NULL); |
| 463 | |
| 464 | response = jsonrpc_stream_success(cmd); |
| 465 | json_add_bool(response, "enabled", true); |
| 466 | json_add_u64(response, "cycle_seconds", cycle_seconds); |
| 467 | json_add_u64(response, "expired_by", timer_cinfo.subsystem_age[EXPIREDINVOICES]); |
| 468 | return command_finished(cmd, response); |
| 469 | } |
| 470 | |
| 471 | static struct command_result *param_subsystem(struct command *cmd, |
| 472 | const char *name, |
nothing calls this directly
no test coverage detected