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

Function wallet_offer_create

wallet/wallet.c:5971–6015  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5969}
5970
5971bool wallet_offer_create(struct wallet *w,
5972 const struct sha256 *offer_id,
5973 const char *bolt12,
5974 const struct json_escape *label,
5975 enum offer_status status,
5976 bool force_paths)
5977{
5978 struct db_stmt *stmt;
5979
5980 assert(offer_status_active(status));
5981
5982 /* Test if already exists. */
5983 stmt = db_prepare_v2(w->db, SQL("SELECT 1"
5984 " FROM offers"
5985 " WHERE offer_id = ?;"));
5986 db_bind_sha256(stmt, offer_id);
5987 db_query_prepared(stmt);
5988
5989 if (db_step(stmt)) {
5990 db_col_ignore(stmt, "1");
5991 tal_free(stmt);
5992 return false;
5993 }
5994 tal_free(stmt);
5995
5996 stmt = db_prepare_v2(w->db,
5997 SQL("INSERT INTO offers ("
5998 " offer_id"
5999 ", bolt12"
6000 ", label"
6001 ", status"
6002 ", force_paths"
6003 ") VALUES (?, ?, ?, ?, ?);"));
6004
6005 db_bind_sha256(stmt, offer_id);
6006 db_bind_text(stmt, bolt12);
6007 if (label)
6008 db_bind_json_escape(stmt, label);
6009 else
6010 db_bind_null(stmt);
6011 db_bind_int(stmt, offer_status_in_db(status));
6012 db_bind_int(stmt, force_paths);
6013 db_exec_prepared_v2(take(stmt));
6014 return true;
6015}
6016
6017char *wallet_offer_find(const tal_t *ctx,
6018 struct wallet *w,

Callers 1

json_createofferFunction · 0.85

Calls 12

offer_status_activeFunction · 0.85
db_bind_sha256Function · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_ignoreFunction · 0.85
tal_freeFunction · 0.85
db_bind_textFunction · 0.85
db_bind_json_escapeFunction · 0.85
db_bind_nullFunction · 0.85
db_bind_intFunction · 0.85
offer_status_in_dbFunction · 0.85
db_exec_prepared_v2Function · 0.85

Tested by

no test coverage detected