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

Function wallet_invoice_request_create

wallet/wallet.c:6173–6214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6171}
6172
6173bool wallet_invoice_request_create(struct wallet *w,
6174 const struct sha256 *invreq_id,
6175 const char *bolt12,
6176 const struct json_escape *label,
6177 enum offer_status status)
6178{
6179 struct db_stmt *stmt;
6180
6181 assert(offer_status_active(status));
6182
6183 /* Test if already exists. */
6184 stmt = db_prepare_v2(w->db, SQL("SELECT 1"
6185 " FROM invoicerequests"
6186 " WHERE invreq_id = ?;"));
6187 db_bind_sha256(stmt, invreq_id);
6188 db_query_prepared(stmt);
6189
6190 if (db_step(stmt)) {
6191 db_col_ignore(stmt, "1");
6192 tal_free(stmt);
6193 return false;
6194 }
6195 tal_free(stmt);
6196
6197 stmt = db_prepare_v2(w->db,
6198 SQL("INSERT INTO invoicerequests ("
6199 " invreq_id"
6200 ", bolt12"
6201 ", label"
6202 ", status"
6203 ") VALUES (?, ?, ?, ?);"));
6204
6205 db_bind_sha256(stmt, invreq_id);
6206 db_bind_text(stmt, bolt12);
6207 if (label)
6208 db_bind_json_escape(stmt, label);
6209 else
6210 db_bind_null(stmt);
6211 db_bind_int(stmt, offer_status_in_db(status));
6212 db_exec_prepared_v2(take(stmt));
6213 return true;
6214}
6215
6216char *wallet_invoice_request_find(const tal_t *ctx,
6217 struct wallet *w,

Callers 1

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