From 9914fd4f8dd48e028a6b00c144b4f772a48c814d Mon Sep 17 00:00:00 2001 From: Arik Sosman Date: Wed, 14 Aug 2024 19:52:01 -0700 Subject: [PATCH] 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. --- lightning-transaction-sync/src/common.rs | 5 +++-- lightning-transaction-sync/src/electrum.rs | 2 +- lightning-transaction-sync/src/esplora.rs | 2 +- lightning-transaction-sync/tests/integration_tests.rs | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lightning-transaction-sync/src/common.rs b/lightning-transaction-sync/src/common.rs index 420d7d8a9..1d6e64bab 100644 --- a/lightning-transaction-sync/src/common.rs +++ b/lightning-transaction-sync/src/common.rs @@ -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); } } diff --git a/lightning-transaction-sync/src/electrum.rs b/lightning-transaction-sync/src/electrum.rs index ddd74743f..015cb42c6 100644 --- a/lightning-transaction-sync/src/electrum.rs +++ b/lightning-transaction-sync/src/electrum.rs @@ -432,7 +432,7 @@ where fn get_confirmed_tx( &self, tx: &Transaction, prob_conf_height: u32, ) -> Result { - 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); diff --git a/lightning-transaction-sync/src/esplora.rs b/lightning-transaction-sync/src/esplora.rs index b3e9285ec..564d7f177 100644 --- a/lightning-transaction-sync/src/esplora.rs +++ b/lightning-transaction-sync/src/esplora.rs @@ -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); } diff --git a/lightning-transaction-sync/tests/integration_tests.rs b/lightning-transaction-sync/tests/integration_tests.rs index 2cf913b56..c887b2be0 100644 --- a/lightning-transaction-sync/tests/integration_tests.rs +++ b/lightning-transaction-sync/tests/integration_tests.rs @@ -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); -- 2.39.5