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

Function trigger_expiration

wallet/invoices.c:179–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179static void trigger_expiration(struct invoices *invoices)
180{
181 u64 *inv_dbids;
182 u64 now = clock_time().ts.tv_sec;
183 struct db_stmt *stmt;
184
185 /* Free current expiration timer */
186 invoices->expiration_timer = tal_free(invoices->expiration_timer);
187
188 inv_dbids = expired_ids(tmpctx, invoices->wallet->db, now, UNPAID);
189
190 /* Trigger expirations */
191 for (size_t i = 0; i < tal_count(inv_dbids); i++) {
192 stmt = db_prepare_v2(invoices->wallet->db, SQL("UPDATE invoices"
193 " SET state = ?"
194 " , updated_index = ?"
195 " WHERE id = ?"));
196 db_bind_int(stmt, EXPIRED);
197 db_bind_u64(stmt,
198 /* FIXME: details! */
199 invoice_index_update_status(invoices->wallet->ld,
200 NULL, EXPIRED));
201 db_bind_u64(stmt, inv_dbids[i]);
202 db_exec_prepared_v2(take(stmt));
203
204 /* Trigger expiration */
205 trigger_invoice_waiter_expire_or_delete(invoices, inv_dbids[i], false);
206 }
207
208 install_expiration_timer(invoices);
209}
210
211static void install_expiration_timer(struct invoices *invoices)
212{

Callers 1

Calls 9

clock_timeFunction · 0.85
tal_freeFunction · 0.85
expired_idsFunction · 0.85
db_bind_intFunction · 0.85
db_bind_u64Function · 0.85
db_exec_prepared_v2Function · 0.85
install_expiration_timerFunction · 0.85

Tested by

no test coverage detected