mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-09 17:14:28 +01:00
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 <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
27835df8fd
commit
5d23698665
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user