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

Function json_autocleaninvoice

plugins/autoclean.c:436–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434}
435
436static 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
471static struct command_result *param_subsystem(struct command *cmd,
472 const char *name,

Callers

nothing calls this directly

Calls 9

tal_freeFunction · 0.85
time_from_secFunction · 0.85
command_param_failedFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
plugin_timerClass · 0.70
paramFunction · 0.50
json_add_boolFunction · 0.50
json_add_u64Function · 0.50

Tested by

no test coverage detected