| 6214 | } |
| 6215 | |
| 6216 | char *wallet_invoice_request_find(const tal_t *ctx, |
| 6217 | struct wallet *w, |
| 6218 | const struct sha256 *invreq_id, |
| 6219 | const struct json_escape **label, |
| 6220 | enum offer_status *status) |
| 6221 | { |
| 6222 | struct db_stmt *stmt; |
| 6223 | char *bolt12; |
| 6224 | |
| 6225 | stmt = db_prepare_v2(w->db, SQL("SELECT bolt12, label, status" |
| 6226 | " FROM invoicerequests" |
| 6227 | " WHERE invreq_id = ?;")); |
| 6228 | db_bind_sha256(stmt, invreq_id); |
| 6229 | db_query_prepared(stmt); |
| 6230 | |
| 6231 | if (!db_step(stmt)) { |
| 6232 | tal_free(stmt); |
| 6233 | return NULL; |
| 6234 | } |
| 6235 | |
| 6236 | bolt12 = db_col_strdup(ctx, stmt, "bolt12"); |
| 6237 | if (label) { |
| 6238 | if (db_col_is_null(stmt, "label")) |
| 6239 | *label = NULL; |
| 6240 | else |
| 6241 | *label = db_col_json_escape(ctx, stmt, "label"); |
| 6242 | } else |
| 6243 | db_col_ignore(stmt, "label"); |
| 6244 | |
| 6245 | if (status) |
| 6246 | *status = offer_status_in_db(db_col_int(stmt, "status")); |
| 6247 | else |
| 6248 | db_col_ignore(stmt, "status"); |
| 6249 | |
| 6250 | tal_free(stmt); |
| 6251 | return bolt12; |
| 6252 | } |
| 6253 | |
| 6254 | struct db_stmt *wallet_invreq_id_first(struct wallet *w, struct sha256 *invreq_id) |
| 6255 | { |
no test coverage detected