| 3818 | } |
| 3819 | |
| 3820 | bool 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 | |
| 3858 | void wallet_utxoset_add(struct wallet *w, |
| 3859 | const struct bitcoin_outpoint *outpoint, |
no test coverage detected