| 6015 | } |
| 6016 | |
| 6017 | char *wallet_offer_find(const tal_t *ctx, |
| 6018 | struct wallet *w, |
| 6019 | const struct sha256 *offer_id, |
| 6020 | const struct json_escape **label, |
| 6021 | enum offer_status *status, |
| 6022 | bool *force_paths) |
| 6023 | { |
| 6024 | struct db_stmt *stmt; |
| 6025 | char *bolt12; |
| 6026 | |
| 6027 | stmt = db_prepare_v2(w->db, SQL("SELECT bolt12, label, status, force_paths" |
| 6028 | " FROM offers" |
| 6029 | " WHERE offer_id = ?;")); |
| 6030 | db_bind_sha256(stmt, offer_id); |
| 6031 | db_query_prepared(stmt); |
| 6032 | |
| 6033 | if (!db_step(stmt)) { |
| 6034 | tal_free(stmt); |
| 6035 | return NULL; |
| 6036 | } |
| 6037 | |
| 6038 | bolt12 = db_col_strdup(ctx, stmt, "bolt12"); |
| 6039 | if (label) { |
| 6040 | if (db_col_is_null(stmt, "label")) |
| 6041 | *label = NULL; |
| 6042 | else |
| 6043 | *label = db_col_json_escape(ctx, stmt, "label"); |
| 6044 | } else |
| 6045 | db_col_ignore(stmt, "label"); |
| 6046 | |
| 6047 | if (status) |
| 6048 | *status = offer_status_in_db(db_col_int(stmt, "status")); |
| 6049 | else |
| 6050 | db_col_ignore(stmt, "status"); |
| 6051 | if (force_paths) |
| 6052 | *force_paths = db_col_int(stmt, "force_paths"); |
| 6053 | else |
| 6054 | db_col_ignore(stmt, "force_paths"); |
| 6055 | |
| 6056 | tal_free(stmt); |
| 6057 | return bolt12; |
| 6058 | } |
| 6059 | |
| 6060 | struct db_stmt *wallet_offer_id_first(struct wallet *w, struct sha256 *offer_id) |
| 6061 | { |
nothing calls this directly
no test coverage detected