| 6303 | } |
| 6304 | |
| 6305 | void 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 | |
| 6340 | void wallet_datastore_update(struct wallet *w, const char **key, const u8 *data) |
| 6341 | { |
no test coverage detected