Browse Source

wallet: Add primitive to register new utxoset outpoint to the wallet

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
27e0ec694c
  1. 30
      wallet/wallet.c
  2. 4
      wallet/wallet.h

30
wallet/wallet.c

@ -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);
}

4
wallet/wallet.h

@ -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…
Cancel
Save