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

Function wallet_outpoint_spend

wallet/wallet.c:4903–4939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4901}
4902
4903bool wallet_outpoint_spend(const tal_t *ctx, struct wallet *w, const u32 blockheight,
4904 const struct bitcoin_outpoint *outpoint)
4905{
4906 struct db_stmt *stmt;
4907 bool our_spend;
4908 if (outpointfilter_matches(w->owned_outpoints, outpoint)) {
4909 stmt = db_prepare_v2(w->db, SQL("UPDATE outputs "
4910 "SET spend_height = ?, "
4911 " status = ? "
4912 "WHERE prev_out_tx = ?"
4913 " AND prev_out_index = ?"));
4914
4915 db_bind_int(stmt, blockheight);
4916 db_bind_int(stmt, output_status_in_db(OUTPUT_STATE_SPENT));
4917 db_bind_txid(stmt, &outpoint->txid);
4918 db_bind_int(stmt, outpoint->n);
4919
4920 db_exec_prepared_v2(take(stmt));
4921
4922 our_spend = true;
4923 } else
4924 our_spend = false;
4925
4926 if (outpointfilter_matches(w->utxoset_outpoints, outpoint)) {
4927 stmt = db_prepare_v2(w->db, SQL("UPDATE utxoset "
4928 "SET spendheight = ? "
4929 "WHERE txid = ?"
4930 " AND outnum = ?"));
4931
4932 db_bind_int(stmt, blockheight);
4933 db_bind_txid(stmt, &outpoint->txid);
4934 db_bind_int(stmt, outpoint->n);
4935 db_exec_prepared_v2(stmt);
4936 tal_free(stmt);
4937 }
4938 return our_spend;
4939}
4940
4941void wallet_utxoset_add(struct wallet *w,
4942 const struct bitcoin_outpoint *outpoint,

Callers 1

topo_update_spendsFunction · 0.85

Calls 6

db_bind_intFunction · 0.85
output_status_in_dbFunction · 0.85
db_bind_txidFunction · 0.85
db_exec_prepared_v2Function · 0.85
tal_freeFunction · 0.85
outpointfilter_matchesFunction · 0.70

Tested by

no test coverage detected