| 4976 | } |
| 4977 | |
| 4978 | char *wallet_offer_find(const tal_t *ctx, |
| 4979 | struct wallet *w, |
| 4980 | const struct sha256 *offer_id, |
| 4981 | const struct json_escape **label, |
| 4982 | enum offer_status *status) |
| 4983 | { |
| 4984 | struct db_stmt *stmt; |
| 4985 | char *bolt12; |
| 4986 | |
| 4987 | stmt = db_prepare_v2(w->db, SQL("SELECT bolt12, label, status" |
| 4988 | " FROM offers" |
| 4989 | " WHERE offer_id = ?;")); |
| 4990 | db_bind_sha256(stmt, 0, offer_id); |
| 4991 | db_query_prepared(stmt); |
| 4992 | |
| 4993 | if (!db_step(stmt)) { |
| 4994 | tal_free(stmt); |
| 4995 | return NULL; |
| 4996 | } |
| 4997 | |
| 4998 | bolt12 = db_col_strdup(ctx, stmt, "bolt12"); |
| 4999 | if (label) { |
| 5000 | if (db_col_is_null(stmt, "label")) |
| 5001 | *label = NULL; |
| 5002 | else |
| 5003 | *label = db_col_json_escape(ctx, stmt, "label"); |
| 5004 | } else |
| 5005 | db_col_ignore(stmt, "label"); |
| 5006 | |
| 5007 | if (status) |
| 5008 | *status = offer_status_in_db(db_col_int(stmt, "status")); |
| 5009 | else |
| 5010 | db_col_ignore(stmt, "status"); |
| 5011 | |
| 5012 | tal_free(stmt); |
| 5013 | return bolt12; |
| 5014 | } |
| 5015 | |
| 5016 | struct db_stmt *wallet_offer_id_first(struct wallet *w, struct sha256 *offer_id) |
| 5017 | { |
nothing calls this directly
no test coverage detected