mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
wallet: Add function to retrieve a watched transaction's blockheight
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
50600ae241
commit
85fbab2fab
@ -2201,3 +2201,20 @@ void wallet_transaction_add(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
db_exec_prepared(w->db, stmt);
|
||||
}
|
||||
}
|
||||
|
||||
u32 wallet_transaction_height(struct wallet *w, const struct bitcoin_txid *txid)
|
||||
{
|
||||
u32 blockheight;
|
||||
sqlite3_stmt *stmt = db_prepare(
|
||||
w->db, "SELECT blockheight, txindex, rawtx FROM transactions WHERE id=?");
|
||||
sqlite3_bind_sha256(stmt, 1, &txid->shad.sha);
|
||||
|
||||
if (sqlite3_step(stmt) != SQLITE_ROW) {
|
||||
sqlite3_finalize(stmt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
blockheight = sqlite3_column_int(stmt, 0);
|
||||
sqlite3_finalize(stmt);
|
||||
return blockheight;
|
||||
}
|
||||
|
@ -814,4 +814,10 @@ void wallet_utxoset_add(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
void wallet_transaction_add(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
const u32 blockheight, const u32 txindex);
|
||||
|
||||
/**
|
||||
* Get the confirmation height of a transaction we are watching by its
|
||||
* txid. Returns 0 if the transaction was not part of any block.
|
||||
*/
|
||||
u32 wallet_transaction_height(struct wallet *w, const struct bitcoin_txid *txid);
|
||||
|
||||
#endif /* LIGHTNING_WALLET_WALLET_H */
|
||||
|
Loading…
Reference in New Issue
Block a user