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

Function wallet_offer_create

wallet/wallet.c:6031–6075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6029}
6030
6031bool wallet_offer_create(struct wallet *w,
6032 const struct sha256 *offer_id,
6033 const char *bolt12,
6034 const struct json_escape *label,
6035 enum offer_status status,
6036 bool force_paths)
6037{
6038 struct db_stmt *stmt;
6039
6040 assert(offer_status_active(status));
6041
6042 /* Test if already exists. */
6043 stmt = db_prepare_v2(w->db, SQL("SELECT 1"
6044 " FROM offers"
6045 " WHERE offer_id = ?;"));
6046 db_bind_sha256(stmt, offer_id);
6047 db_query_prepared(stmt);
6048
6049 if (db_step(stmt)) {
6050 db_col_ignore(stmt, "1");
6051 tal_free(stmt);
6052 return false;
6053 }
6054 tal_free(stmt);
6055
6056 stmt = db_prepare_v2(w->db,
6057 SQL("INSERT INTO offers ("
6058 " offer_id"
6059 ", bolt12"
6060 ", label"
6061 ", status"
6062 ", force_paths"
6063 ") VALUES (?, ?, ?, ?, ?);"));
6064
6065 db_bind_sha256(stmt, offer_id);
6066 db_bind_text(stmt, bolt12);
6067 if (label)
6068 db_bind_json_escape(stmt, label);
6069 else
6070 db_bind_null(stmt);
6071 db_bind_int(stmt, offer_status_in_db(status));
6072 db_bind_int(stmt, force_paths);
6073 db_exec_prepared_v2(take(stmt));
6074 return true;
6075}
6076
6077char *wallet_offer_find(const tal_t *ctx,
6078 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