mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
wallet: Add outpointfilter for the utxoset
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
ec014be2a8
commit
d8d11e5689
@ -18,13 +18,27 @@
|
||||
|
||||
static void outpointfilters_init(struct wallet *w)
|
||||
{
|
||||
sqlite3_stmt *stmt;
|
||||
struct utxo **utxos = wallet_get_utxos(NULL, w, output_state_any);
|
||||
struct bitcoin_txid txid;
|
||||
u32 outnum;
|
||||
|
||||
w->owned_outpoints = outpointfilter_new(w);
|
||||
for (size_t i = 0; i < tal_count(utxos); i++)
|
||||
outpointfilter_add(w->owned_outpoints, &utxos[i]->txid, utxos[i]->outnum);
|
||||
|
||||
tal_free(utxos);
|
||||
|
||||
w->utxoset_outpoints = outpointfilter_new(w);
|
||||
stmt = db_prepare(w->db, "SELECT txid, outnum FROM utxoset WHERE spendheight is NULL");
|
||||
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
sqlite3_column_sha256_double(stmt, 0, &txid.shad);
|
||||
outnum = sqlite3_column_int(stmt, 1);
|
||||
outpointfilter_add(w->utxoset_outpoints, &txid, outnum);
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
|
||||
struct wallet *wallet_new(struct lightningd *ld,
|
||||
|
@ -36,6 +36,10 @@ struct wallet {
|
||||
/* Filter matching all outpoints corresponding to our owned outputs,
|
||||
* including all spent ones */
|
||||
struct outpointfilter *owned_outpoints;
|
||||
|
||||
/* Filter matching all outpoints that might be a funding transaction on
|
||||
* the blockchain. This is currently all P2WSH outputs */
|
||||
struct outpointfilter *utxoset_outpoints;
|
||||
};
|
||||
|
||||
/* Possible states for tracked outputs in the database. Not sure yet
|
||||
|
Loading…
Reference in New Issue
Block a user