MCPcopy Create free account
hub / github.com/ElementsProject/lightning / wallet_offer_find

Function wallet_offer_find

wallet/wallet.c:4978–5014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4976}
4977
4978char *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
5016struct db_stmt *wallet_offer_id_first(struct wallet *w, struct sha256 *offer_id)
5017{

Callers

nothing calls this directly

Calls 10

db_bind_sha256Function · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
tal_freeFunction · 0.85
db_col_strdupFunction · 0.85
db_col_is_nullFunction · 0.85
db_col_json_escapeFunction · 0.85
db_col_ignoreFunction · 0.85
offer_status_in_dbFunction · 0.85
db_col_intFunction · 0.85

Tested by

no test coverage detected