| 64 | #endif /* DB_FATAL */ |
| 65 | |
| 66 | static void outpointfilters_init(struct wallet *w) |
| 67 | { |
| 68 | struct db_stmt *stmt; |
| 69 | struct utxo **utxos = wallet_get_utxos(NULL, w, OUTPUT_STATE_ANY); |
| 70 | struct bitcoin_outpoint outpoint; |
| 71 | |
| 72 | w->owned_outpoints = outpointfilter_new(w); |
| 73 | for (size_t i = 0; i < tal_count(utxos); i++) |
| 74 | outpointfilter_add(w->owned_outpoints, &utxos[i]->outpoint); |
| 75 | |
| 76 | tal_free(utxos); |
| 77 | |
| 78 | w->utxoset_outpoints = outpointfilter_new(w); |
| 79 | stmt = db_prepare_v2( |
| 80 | w->db, |
| 81 | SQL("SELECT txid, outnum FROM utxoset WHERE spendheight is NULL")); |
| 82 | db_query_prepared(stmt); |
| 83 | |
| 84 | while (db_step(stmt)) { |
| 85 | db_col_txid(stmt, "txid", &outpoint.txid); |
| 86 | outpoint.n = db_col_int(stmt, "outnum"); |
| 87 | outpointfilter_add(w->utxoset_outpoints, &outpoint); |
| 88 | } |
| 89 | tal_free(stmt); |
| 90 | } |
| 91 | |
| 92 | struct wallet *wallet_new(struct lightningd *ld, struct timers *timers, |
| 93 | struct ext_key *bip32_base STEALS) |
no test coverage detected