Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
5d23698665
  1. 8
      wallet/wallet.c
  2. 7
      wallet/wallet.h

8
wallet/wallet.c

@ -1055,9 +1055,8 @@ void wallet_peer_delete(struct wallet *w, u64 peer_dbid)
db_exec_prepared(w->db, stmt); db_exec_prepared(w->db, stmt);
} }
static void wallet_output_confirm(struct wallet *w, void wallet_confirm_tx(struct wallet *w,
const struct bitcoin_txid *txid, const struct bitcoin_txid *txid,
const u32 outnum,
const u32 confirmation_height) const u32 confirmation_height)
{ {
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
@ -1065,10 +1064,9 @@ static void wallet_output_confirm(struct wallet *w,
stmt = db_prepare(w->db, stmt = db_prepare(w->db,
"UPDATE outputs " "UPDATE outputs "
"SET confirmation_height = ? " "SET confirmation_height = ? "
"WHERE prev_out_tx = ? AND prev_out_index = ?"); "WHERE prev_out_tx = ?");
sqlite3_bind_int(stmt, 1, confirmation_height); sqlite3_bind_int(stmt, 1, confirmation_height);
sqlite3_bind_sha256_double(stmt, 2, &txid->shad); sqlite3_bind_sha256_double(stmt, 2, &txid->shad);
sqlite3_bind_int(stmt, 3, outnum);
db_exec_prepared(w->db, stmt); 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 * the output from a transaction we created
* ourselves. */ * ourselves. */
if (blockheight) if (blockheight)
wallet_output_confirm(w, &utxo->txid, utxo->outnum, *blockheight); wallet_confirm_tx(w, &utxo->txid, *blockheight);
tal_free(utxo); tal_free(utxo);
continue; continue;
} }

7
wallet/wallet.h

@ -225,6 +225,13 @@ struct wallet *wallet_new(struct lightningd *ld,
bool wallet_add_utxo(struct wallet *w, struct utxo *utxo, bool wallet_add_utxo(struct wallet *w, struct utxo *utxo,
enum wallet_output_type type); 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 * wallet_update_output_status - Perform an output state transition
* *

Loading…
Cancel
Save