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

Function listinvoices_done

plugins/autoclean.c:180–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180static struct command_result *listinvoices_done(struct command *cmd,
181 const char *buf,
182 const jsmntok_t *result,
183 struct clean_info *cinfo)
184{
185 const jsmntok_t *t, *inv = json_get_member(buf, result, "invoices");
186 size_t i;
187 u64 now = time_now().ts.tv_sec;
188
189 json_for_each_arr(i, t, inv) {
190 const jsmntok_t *status = json_get_member(buf, t, "status");
191 const jsmntok_t *time;
192 enum subsystem subsys;
193 u64 invtime;
194
195 if (json_tok_streq(buf, status, "expired")) {
196 subsys = EXPIREDINVOICES;
197 time = json_get_member(buf, t, "expires_at");
198 } else if (json_tok_streq(buf, status, "paid")) {
199 subsys = PAIDINVOICES;
200 time = json_get_member(buf, t, "paid_at");
201 } else {
202 cinfo->num_uncleaned++;
203 continue;
204 }
205
206 /* Continue if we don't care. */
207 if (cinfo->subsystem_age[subsys] == 0) {
208 cinfo->num_uncleaned++;
209 continue;
210 }
211
212 if (!json_to_u64(buf, time, &invtime)) {
213 plugin_err(plugin, "Bad time '%.*s'",
214 json_tok_full_len(time),
215 json_tok_full(buf, time));
216 }
217
218 if (invtime <= now - cinfo->subsystem_age[subsys]) {
219 struct out_req *req;
220 const jsmntok_t *label = json_get_member(buf, t, "label");
221
222 req = del_request_start("delinvoice", cinfo, subsys);
223 json_add_tok(req->js, "label", label, buf);
224 json_add_tok(req->js, "status", status, buf);
225 send_outreq(plugin, req);
226 }
227 }
228
229 if (cinfo->cleanup_reqs_remaining)
230 return command_still_pending(cmd);
231 return clean_finished(cinfo);
232}
233
234static struct command_result *listsendpays_done(struct command *cmd,
235 const char *buf,

Callers

nothing calls this directly

Calls 12

time_nowFunction · 0.85
del_request_startFunction · 0.85
json_add_tokFunction · 0.85
clean_finishedFunction · 0.85
plugin_errFunction · 0.70
send_outreqFunction · 0.70
command_still_pendingFunction · 0.70
json_get_memberFunction · 0.50
json_tok_streqFunction · 0.50
json_to_u64Function · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected