If we make an offer inactive, this also expires all invoices * which we issued for it. */
| 5037 | /* If we make an offer inactive, this also expires all invoices |
| 5038 | * which we issued for it. */ |
| 5039 | static void offer_status_update(struct db *db, |
| 5040 | const struct sha256 *offer_id, |
| 5041 | enum offer_status oldstatus, |
| 5042 | enum offer_status newstatus) |
| 5043 | { |
| 5044 | struct db_stmt *stmt; |
| 5045 | |
| 5046 | stmt = db_prepare_v2(db, SQL("UPDATE offers" |
| 5047 | " SET status=?" |
| 5048 | " WHERE offer_id = ?;")); |
| 5049 | db_bind_int(stmt, 0, offer_status_in_db(newstatus)); |
| 5050 | db_bind_sha256(stmt, 1, offer_id); |
| 5051 | db_exec_prepared_v2(take(stmt)); |
| 5052 | |
| 5053 | if (!offer_status_active(oldstatus) |
| 5054 | || offer_status_active(newstatus)) |
| 5055 | return; |
| 5056 | |
| 5057 | stmt = db_prepare_v2(db, SQL("UPDATE invoices" |
| 5058 | " SET state=?" |
| 5059 | " WHERE state=? AND local_offer_id = ?;")); |
| 5060 | db_bind_int(stmt, 0, invoice_status_in_db(EXPIRED)); |
| 5061 | db_bind_int(stmt, 1, invoice_status_in_db(UNPAID)); |
| 5062 | db_bind_sha256(stmt, 2, offer_id); |
| 5063 | db_exec_prepared_v2(take(stmt)); |
| 5064 | } |
| 5065 | |
| 5066 | enum offer_status wallet_offer_disable(struct wallet *w, |
| 5067 | const struct sha256 *offer_id, |
no test coverage detected