| 6136 | } |
| 6137 | |
| 6138 | void 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 | |
| 6173 | bool wallet_invoice_request_create(struct wallet *w, |
| 6174 | const struct sha256 *invreq_id, |
no test coverage detected