mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 02:39:28 +01:00
wallet: Add primitive to register new utxoset outpoint to the wallet
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
d8d11e5689
commit
27e0ec694c
2 changed files with 34 additions and 0 deletions
|
@ -1816,3 +1816,33 @@ void wallet_outpoint_spend(struct wallet *w, const u32 blockheight,
|
|||
db_exec_prepared(w->db, stmt);
|
||||
}
|
||||
}
|
||||
|
||||
void wallet_utxoset_add(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
const u32 outnum, const u32 blockheight,
|
||||
const u32 txindex, const u8 *scriptpubkey,
|
||||
const u64 satoshis)
|
||||
{
|
||||
sqlite3_stmt *stmt;
|
||||
struct bitcoin_txid txid;
|
||||
bitcoin_txid(tx, &txid);
|
||||
|
||||
stmt = db_prepare(w->db, "INSERT INTO utxoset ("
|
||||
" txid,"
|
||||
" outnum,"
|
||||
" blockheight,"
|
||||
" spendheight,"
|
||||
" txindex,"
|
||||
" scriptpubkey,"
|
||||
" satoshis"
|
||||
") VALUES(?, ?, ?, ?, ?, ?, ?);");
|
||||
sqlite3_bind_sha256_double(stmt, 1, &txid.shad);
|
||||
sqlite3_bind_int(stmt, 2, outnum);
|
||||
sqlite3_bind_int(stmt, 3, blockheight);
|
||||
sqlite3_bind_null(stmt, 4);
|
||||
sqlite3_bind_int(stmt, 5, txindex);
|
||||
sqlite3_bind_blob(stmt, 6, scriptpubkey, tal_len(scriptpubkey), SQLITE_TRANSIENT);
|
||||
sqlite3_bind_int64(stmt, 7, satoshis);
|
||||
db_exec_prepared(w->db, stmt);
|
||||
|
||||
outpointfilter_add(w->utxoset_outpoints, &txid, outnum);
|
||||
}
|
||||
|
|
|
@ -711,4 +711,8 @@ void wallet_blocks_rollback(struct wallet *w, u32 height);
|
|||
void wallet_outpoint_spend(struct wallet *w, const u32 blockheight,
|
||||
const struct bitcoin_txid *txid, const u32 outnum);
|
||||
|
||||
void wallet_utxoset_add(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
const u32 outnum, const u32 blockheight,
|
||||
const u32 txindex, const u8 *scriptpubkey,
|
||||
const u64 satoshis);
|
||||
#endif /* WALLET_WALLET_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue