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

Function wallet_outpoint_spend

wallet/wallet.c:3820–3856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3818}
3819
3820bool wallet_outpoint_spend(struct wallet *w, const tal_t *ctx, const u32 blockheight,
3821 const struct bitcoin_outpoint *outpoint)
3822{
3823 struct db_stmt *stmt;
3824 bool our_spend;
3825 if (outpointfilter_matches(w->owned_outpoints, outpoint)) {
3826 stmt = db_prepare_v2(w->db, SQL("UPDATE outputs "
3827 "SET spend_height = ?, "
3828 " status = ? "
3829 "WHERE prev_out_tx = ?"
3830 " AND prev_out_index = ?"));
3831
3832 db_bind_int(stmt, 0, blockheight);
3833 db_bind_int(stmt, 1, output_status_in_db(OUTPUT_STATE_SPENT));
3834 db_bind_txid(stmt, 2, &outpoint->txid);
3835 db_bind_int(stmt, 3, outpoint->n);
3836
3837 db_exec_prepared_v2(take(stmt));
3838
3839 our_spend = true;
3840 } else
3841 our_spend = false;
3842
3843 if (outpointfilter_matches(w->utxoset_outpoints, outpoint)) {
3844 stmt = db_prepare_v2(w->db, SQL("UPDATE utxoset "
3845 "SET spendheight = ? "
3846 "WHERE txid = ?"
3847 " AND outnum = ?"));
3848
3849 db_bind_int(stmt, 0, blockheight);
3850 db_bind_txid(stmt, 1, &outpoint->txid);
3851 db_bind_int(stmt, 2, outpoint->n);
3852 db_exec_prepared_v2(stmt);
3853 tal_free(stmt);
3854 }
3855 return our_spend;
3856}
3857
3858void wallet_utxoset_add(struct wallet *w,
3859 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