Fix lightning-transaction sync warnings.

Version 0.32.2 of `rust-bitcoin` deprecates a number of methods that
are commonly used in this project, most visibly `txid()`, which is
now called `compute_txid()`. This resulted in a lot of warnings, and
this commit is part of a series that seeks to address that.
This commit is contained in:
Arik Sosman 2024-08-14 19:52:01 -07:00
parent 92aac2a2ae
commit 9914fd4f8d
No known key found for this signature in database
GPG key ID: CFF795E7811C0093
4 changed files with 6 additions and 5 deletions

View file

@ -74,11 +74,12 @@ impl SyncState {
);
}
self.watched_transactions.remove(&ctx.tx.txid());
self.watched_transactions.remove(&ctx.tx.compute_txid());
for input in &ctx.tx.input {
if let Some(output) = self.watched_outputs.remove(&input.previous_output) {
let spent = (ctx.tx.txid(), ctx.block_height, input.previous_output, output);
let spent =
(ctx.tx.compute_txid(), ctx.block_height, input.previous_output, output);
self.outputs_spends_pending_threshold_conf.push(spent);
}
}

View file

@ -432,7 +432,7 @@ where
fn get_confirmed_tx(
&self, tx: &Transaction, prob_conf_height: u32,
) -> Result<ConfirmedTx, InternalError> {
let txid = tx.txid();
let txid = tx.compute_txid();
match self.client.transaction_get_merkle(&txid, prob_conf_height as usize) {
Ok(merkle_res) => {
debug_assert_eq!(prob_conf_height, merkle_res.block_height as u32);

View file

@ -367,7 +367,7 @@ where
// unwrap() safety: len() > 0 is checked above
let pos = *indexes.first().unwrap() as usize;
if let Some(tx) = maybe_await!(self.client.get_tx(&txid))? {
if tx.txid() != txid {
if tx.compute_txid() != txid {
log_error!(self.logger, "Retrieved transaction for txid {} doesn't match expectations. This should not happen. Please verify server integrity.", txid);
return Err(InternalError::Failed);
}

View file

@ -134,7 +134,7 @@ impl TestConfirmable {
impl Confirm for TestConfirmable {
fn transactions_confirmed(&self, header: &Header, txdata: &TransactionData<'_>, height: u32) {
for (_, tx) in txdata {
let txid = tx.txid();
let txid = tx.compute_txid();
let block_hash = header.block_hash();
self.confirmed_txs.lock().unwrap().insert(txid, (block_hash, height));
self.unconfirmed_txs.lock().unwrap().remove(&txid);