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

Function wallet_offer_mark_used

wallet/wallet.c:6138–6171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6136}
6137
6138void wallet_offer_mark_used(struct db *db, const struct sha256 *offer_id)
6139{
6140 struct db_stmt *stmt;
6141 enum offer_status status;
6142
6143 stmt = db_prepare_v2(db, SQL("SELECT status"
6144 " FROM offers"
6145 " WHERE offer_id = ?;"));
6146 db_bind_sha256(stmt, offer_id);
6147 db_query_prepared(stmt);
6148 if (!db_step(stmt))
6149 fatal("%s: unknown offer_id %s",
6150 __func__,
6151 fmt_sha256(tmpctx, offer_id));
6152
6153 status = offer_status_in_db(db_col_int(stmt, "status"));
6154 tal_free(stmt);
6155
6156 if (!offer_status_active(status))
6157 fatal("%s: offer_id %s not active: status %i",
6158 __func__,
6159 fmt_sha256(tmpctx, offer_id),
6160 status);
6161
6162 if (!offer_status_used(status)) {
6163 enum offer_status newstatus;
6164
6165 if (offer_status_single(status))
6166 newstatus = OFFER_SINGLE_USE_USED;
6167 else
6168 newstatus = OFFER_MULTIPLE_USE_USED;
6169 offer_status_update(db, offer_id, status, newstatus);
6170 }
6171}
6172
6173bool wallet_invoice_request_create(struct wallet *w,
6174 const struct sha256 *invreq_id,

Callers 1

maybe_mark_offer_usedFunction · 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
offer_status_updateFunction · 0.85
fatalFunction · 0.50

Tested by

no test coverage detected