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

Function wallet_offer_mark_used

wallet/wallet.c:5080–5113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5078}
5079
5080void wallet_offer_mark_used(struct db *db, const struct sha256 *offer_id)
5081{
5082 struct db_stmt *stmt;
5083 enum offer_status status;
5084
5085 stmt = db_prepare_v2(db, SQL("SELECT status"
5086 " FROM offers"
5087 " WHERE offer_id = ?;"));
5088 db_bind_sha256(stmt, 0, offer_id);
5089 db_query_prepared(stmt);
5090 if (!db_step(stmt))
5091 fatal("%s: unknown offer_id %s",
5092 __func__,
5093 type_to_string(tmpctx, struct sha256, offer_id));
5094
5095 status = offer_status_in_db(db_col_int(stmt, "status"));
5096 tal_free(stmt);
5097
5098 if (!offer_status_active(status))
5099 fatal("%s: offer_id %s not active: status %i",
5100 __func__,
5101 type_to_string(tmpctx, struct sha256, offer_id),
5102 status);
5103
5104 if (!offer_status_used(status)) {
5105 enum offer_status newstatus;
5106
5107 if (offer_status_single(status))
5108 newstatus = OFFER_SINGLE_USE_USED;
5109 else
5110 newstatus = OFFER_MULTIPLE_USE_USED;
5111 offer_status_update(db, offer_id, status, newstatus);
5112 }
5113}
5114
5115
5116/* We join key parts with nuls for now. */

Callers 2

maybe_mark_offer_usedFunction · 0.85
payment_succeededFunction · 0.85

Calls 12

db_bind_sha256Function · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 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
offer_status_updateFunction · 0.85
fatalFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected