From 5d2369866502af014ef04b97234e3779a44dd60d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 13 Aug 2018 12:33:08 +0930 Subject: [PATCH] wallet: expose function to confirm a tx. Note that we don't actually need the output number: it's the tx itself which is confirmed. And the next caller doesn't have it convenient, so eliminate it. Signed-off-by: Rusty Russell --- wallet/wallet.c | 12 +++++------- wallet/wallet.h | 7 +++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/wallet/wallet.c b/wallet/wallet.c index b0cb57180..449966a85 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1055,20 +1055,18 @@ void wallet_peer_delete(struct wallet *w, u64 peer_dbid) db_exec_prepared(w->db, stmt); } -static void wallet_output_confirm(struct wallet *w, - const struct bitcoin_txid *txid, - const u32 outnum, - const u32 confirmation_height) +void wallet_confirm_tx(struct wallet *w, + const struct bitcoin_txid *txid, + const u32 confirmation_height) { sqlite3_stmt *stmt; assert(confirmation_height > 0); stmt = db_prepare(w->db, "UPDATE outputs " "SET confirmation_height = ? " - "WHERE prev_out_tx = ? AND prev_out_index = ?"); + "WHERE prev_out_tx = ?"); sqlite3_bind_int(stmt, 1, confirmation_height); sqlite3_bind_sha256_double(stmt, 2, &txid->shad); - sqlite3_bind_int(stmt, 3, outnum); db_exec_prepared(w->db, stmt); } @@ -1111,7 +1109,7 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, * the output from a transaction we created * ourselves. */ if (blockheight) - wallet_output_confirm(w, &utxo->txid, utxo->outnum, *blockheight); + wallet_confirm_tx(w, &utxo->txid, *blockheight); tal_free(utxo); continue; } diff --git a/wallet/wallet.h b/wallet/wallet.h index 9e1a20940..5c1f56b09 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -225,6 +225,13 @@ struct wallet *wallet_new(struct lightningd *ld, bool wallet_add_utxo(struct wallet *w, struct utxo *utxo, enum wallet_output_type type); +/** + * wallet_confirm_tx - Confirm a tx which contains a UTXO. + */ +void wallet_confirm_tx(struct wallet *w, + const struct bitcoin_txid *txid, + const u32 confirmation_height); + /** * wallet_update_output_status - Perform an output state transition *