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

Function wallet_invoice_request_mark_used

wallet/wallet.c:6305–6338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6303}
6304
6305void wallet_invoice_request_mark_used(struct db *db, const struct sha256 *invreq_id)
6306{
6307 struct db_stmt *stmt;
6308 enum offer_status status;
6309
6310 stmt = db_prepare_v2(db, SQL("SELECT status"
6311 " FROM invoicerequests"
6312 " WHERE invreq_id = ?;"));
6313 db_bind_sha256(stmt, invreq_id);
6314 db_query_prepared(stmt);
6315 if (!db_step(stmt))
6316 fatal("%s: unknown invreq_id %s",
6317 __func__,
6318 fmt_sha256(tmpctx, invreq_id));
6319
6320 status = offer_status_in_db(db_col_int(stmt, "status"));
6321 tal_free(stmt);
6322
6323 if (!offer_status_active(status))
6324 fatal("%s: invreq_id %s not active: status %i",
6325 __func__,
6326 fmt_sha256(tmpctx, invreq_id),
6327 status);
6328
6329 if (!offer_status_used(status)) {
6330 enum offer_status newstatus;
6331
6332 if (offer_status_single(status))
6333 newstatus = OFFER_SINGLE_USE_USED;
6334 else
6335 newstatus = OFFER_MULTIPLE_USE_USED;
6336 invoice_request_status_update(db, invreq_id, status, newstatus);
6337 }
6338}
6339
6340void wallet_datastore_update(struct wallet *w, const char **key, const u8 *data)
6341{

Callers 1

payment_succeededFunction · 0.85

Calls 12

db_bind_sha256Function · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
fmt_sha256Function · 0.85
offer_status_in_dbFunction · 0.85
db_col_intFunction · 0.85
tal_freeFunction · 0.85
offer_status_activeFunction · 0.85
offer_status_usedFunction · 0.85
offer_status_singleFunction · 0.85
fatalFunction · 0.50

Tested by

no test coverage detected