Skip to content

Commit f5a71ae

Browse files
committed
Fix deprecated method calls.
1 parent 110bd6b commit f5a71ae

23 files changed

+205
-203
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,10 @@ mod tests {
18661866
nodes[0]
18671867
.node
18681868
.force_close_broadcasting_latest_txn(
1869-
&ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.txid(), index: 0 }),
1869+
&ChannelId::v1_from_funding_outpoint(OutPoint {
1870+
txid: tx.compute_txid(),
1871+
index: 0,
1872+
}),
18701873
&nodes[1].node.get_our_node_id(),
18711874
error_message.to_string(),
18721875
)
@@ -2134,7 +2137,7 @@ mod tests {
21342137
get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, node_0_id);
21352138
let broadcast_funding =
21362139
nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().pop().unwrap();
2137-
assert_eq!(broadcast_funding.txid(), funding_tx.txid());
2140+
assert_eq!(broadcast_funding.compute_txid(), funding_tx.compute_txid());
21382141
assert!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().is_empty());
21392142

21402143
if !std::thread::panicking() {
@@ -2212,7 +2215,7 @@ mod tests {
22122215
let sweep_tx_0 = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().pop().unwrap();
22132216
match tracked_output.status {
22142217
OutputSpendStatus::PendingFirstConfirmation { latest_spending_tx, .. } => {
2215-
assert_eq!(sweep_tx_0.txid(), latest_spending_tx.txid());
2218+
assert_eq!(sweep_tx_0.compute_txid(), latest_spending_tx.compute_txid());
22162219
},
22172220
_ => panic!("Unexpected status"),
22182221
}
@@ -2224,7 +2227,7 @@ mod tests {
22242227
let sweep_tx_1 = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().pop().unwrap();
22252228
match tracked_output.status {
22262229
OutputSpendStatus::PendingFirstConfirmation { latest_spending_tx, .. } => {
2227-
assert_eq!(sweep_tx_1.txid(), latest_spending_tx.txid());
2230+
assert_eq!(sweep_tx_1.compute_txid(), latest_spending_tx.compute_txid());
22282231
},
22292232
_ => panic!("Unexpected status"),
22302233
}
@@ -2236,7 +2239,7 @@ mod tests {
22362239
let sweep_tx_2 = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().pop().unwrap();
22372240
match tracked_output.status {
22382241
OutputSpendStatus::PendingFirstConfirmation { latest_spending_tx, .. } => {
2239-
assert_eq!(sweep_tx_2.txid(), latest_spending_tx.txid());
2242+
assert_eq!(sweep_tx_2.compute_txid(), latest_spending_tx.compute_txid());
22402243
},
22412244
_ => panic!("Unexpected status"),
22422245
}
@@ -2249,7 +2252,7 @@ mod tests {
22492252
let tracked_output = nodes[0].sweeper.tracked_spendable_outputs().first().unwrap().clone();
22502253
match tracked_output.status {
22512254
OutputSpendStatus::PendingThresholdConfirmations { latest_spending_tx, .. } => {
2252-
assert_eq!(sweep_tx_2.txid(), latest_spending_tx.txid());
2255+
assert_eq!(sweep_tx_2.compute_txid(), latest_spending_tx.compute_txid());
22532256
},
22542257
_ => panic!("Unexpected status"),
22552258
}
@@ -2264,7 +2267,7 @@ mod tests {
22642267
let tracked_output = nodes[0].sweeper.tracked_spendable_outputs().first().unwrap().clone();
22652268
match tracked_output.status {
22662269
OutputSpendStatus::PendingThresholdConfirmations { latest_spending_tx, .. } => {
2267-
assert_eq!(sweep_tx_2.txid(), latest_spending_tx.txid());
2270+
assert_eq!(sweep_tx_2.compute_txid(), latest_spending_tx.compute_txid());
22682271
},
22692272
_ => panic!("Unexpected status"),
22702273
}

lightning-block-sync/src/gossip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ where
198198
return Err(UtxoLookupError::UnknownTx);
199199
}
200200

201-
outpoint = OutPoint::new(transaction.txid(), output_index.into());
201+
outpoint = OutPoint::new(transaction.compute_txid(), output_index.into());
202202
output = transaction.output[output_index as usize].clone();
203203
}};
204204
}

lightning-block-sync/src/poll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl ValidatedBlockHeader {
144144
if self.height % 2016 == 0 {
145145
let target = self.header.target();
146146
let previous_target = previous_header.header.target();
147-
let min_target = previous_target.min_difficulty_transition_threshold();
147+
let min_target = previous_target.min_transition_threshold();
148148
let max_target = previous_target.max_difficulty_transition_threshold();
149149
if target > max_target || target < min_target {
150150
return Err(BlockSourceError::persistent("invalid difficulty transition"));

lightning-block-sync/src/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Blockchain {
5353
input: vec![],
5454
output: vec![],
5555
};
56-
let merkle_root = TxMerkleNode::from_raw_hash(coinbase.txid().to_raw_hash());
56+
let merkle_root = TxMerkleNode::from_raw_hash(coinbase.compute_txid().to_raw_hash());
5757
self.blocks.push(Block {
5858
header: Header {
5959
version: Version::NO_SOFT_FORK_SIGNALLING,

lightning/src/blinded_path/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,11 @@ impl Writeable for BlindedPath {
275275

276276
impl Readable for BlindedPath {
277277
fn read<R: io::Read>(r: &mut R) -> Result<Self, DecodeError> {
278-
let mut first_byte: u8 = Readable::read(r)?;
278+
let first_byte: u8 = Readable::read(r)?;
279279
let introduction_node = match first_byte {
280280
0 => IntroductionNode::DirectedShortChannelId(Direction::NodeOne, Readable::read(r)?),
281281
1 => IntroductionNode::DirectedShortChannelId(Direction::NodeTwo, Readable::read(r)?),
282282
2|3 => {
283-
use io::Read;
284283
let mut bytes = [0; 33];
285284
bytes[0] = first_byte;
286285
r.read_exact(&mut bytes[1..])?;

lightning/src/chain/channelmonitor.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
21432143
} = &event.event {
21442144
if event.transaction.as_ref().map(|tx| tx.input.iter().any(|inp| {
21452145
if let Some(htlc_spend_txid) = htlc_spend_txid_opt {
2146-
tx.txid() == *htlc_spend_txid || inp.previous_output.txid == *htlc_spend_txid
2146+
tx.compute_txid() == *htlc_spend_txid || inp.previous_output.txid == *htlc_spend_txid
21472147
} else {
21482148
Some(inp.previous_output.txid) == confirmed_txid &&
21492149
inp.previous_output.vout == htlc_commitment_tx_output_idx
@@ -2592,7 +2592,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
25922592
macro_rules! fail_unbroadcast_htlcs {
25932593
($self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr, $commitment_tx_confirmed: expr,
25942594
$commitment_tx_conf_height: expr, $commitment_tx_conf_hash: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
2595-
debug_assert_eq!($commitment_tx_confirmed.txid(), $commitment_txid_confirmed);
2595+
debug_assert_eq!($commitment_tx_confirmed.compute_txid(), $commitment_txid_confirmed);
25962596

25972597
macro_rules! check_htlc_fails {
25982598
($txid: expr, $commitment_tx: expr, $per_commitment_outpoints: expr) => {
@@ -3225,7 +3225,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
32253225
// introduced with v0.0.116. counterparty_node_id is guaranteed to be `Some`
32263226
// since v0.0.110.
32273227
let counterparty_node_id = self.counterparty_node_id.unwrap();
3228-
let commitment_txid = commitment_tx.txid();
3228+
let commitment_txid = commitment_tx.compute_txid();
32293229
debug_assert_eq!(self.current_holder_commitment_tx.txid, commitment_txid);
32303230
let pending_htlcs = self.current_holder_commitment_tx.non_dust_htlcs();
32313231
let commitment_tx_fee_satoshis = self.channel_value_satoshis -
@@ -3405,7 +3405,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
34053405
let mut claimable_outpoints = Vec::new();
34063406
let mut to_counterparty_output_info = None;
34073407

3408-
let commitment_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
3408+
let commitment_txid = tx.compute_txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
34093409
let per_commitment_option = self.counterparty_claimable_outpoints.get(&commitment_txid);
34103410

34113411
macro_rules! ignore_error {
@@ -3591,7 +3591,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35913591
};
35923592
let per_commitment_point = PublicKey::from_secret_key(&self.onchain_tx_handler.secp_ctx, &per_commitment_key);
35933593

3594-
let htlc_txid = tx.txid();
3594+
let htlc_txid = tx.compute_txid();
35953595
let mut claimable_outpoints = vec![];
35963596
let mut outputs_to_watch = None;
35973597
// Previously, we would only claim HTLCs from revoked HTLC transactions if they had 1 input
@@ -3683,7 +3683,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36833683
/// Should not be used if check_spend_revoked_transaction succeeds.
36843684
/// Returns None unless the transaction is definitely one of our commitment transactions.
36853685
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, block_hash: &BlockHash, logger: &L) -> Option<(Vec<PackageTemplate>, TransactionOutputs)> where L::Target: Logger {
3686-
let commitment_txid = tx.txid();
3686+
let commitment_txid = tx.compute_txid();
36873687
let mut claim_requests = Vec::new();
36883688
let mut watch_outputs = Vec::new();
36893689

@@ -3788,7 +3788,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
37883788
) -> Vec<Transaction> where L::Target: Logger {
37893789
log_debug!(logger, "Getting signed copy of latest holder commitment transaction!");
37903790
let commitment_tx = self.onchain_tx_handler.get_fully_signed_copy_holder_tx(&self.funding_redeemscript);
3791-
let txid = commitment_tx.txid();
3791+
let txid = commitment_tx.compute_txid();
37923792
let mut holder_transactions = vec![commitment_tx];
37933793
// When anchor outputs are present, the HTLC transactions are only final once the commitment
37943794
// transaction confirms due to the CSV 1 encumberance.
@@ -3887,7 +3887,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
38873887
let mut watch_outputs = Vec::new();
38883888
let mut claimable_outpoints = Vec::new();
38893889
'tx_iter: for tx in &txn_matched {
3890-
let txid = tx.txid();
3890+
let txid = tx.compute_txid();
38913891
log_trace!(logger, "Transaction {} confirmed in block {}", txid , block_hash);
38923892
// If a transaction has already been confirmed, ensure we don't bother processing it duplicatively.
38933893
if Some(txid) == self.funding_spend_confirmed {
@@ -4133,7 +4133,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41334133
// make sure the registered scriptpubkey at the expected index match
41344134
// the actual transaction output one. We failed this case before #653.
41354135
for tx in &txn_matched {
4136-
if let Some(outputs) = self.get_outputs_to_watch().get(&tx.txid()) {
4136+
if let Some(outputs) = self.get_outputs_to_watch().get(&tx.compute_txid()) {
41374137
for idx_and_script in outputs.iter() {
41384138
assert!((idx_and_script.0 as usize) < tx.output.len());
41394139
assert_eq!(tx.output[idx_and_script.0 as usize].script_pubkey, idx_and_script.1);
@@ -4208,7 +4208,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
42084208
}
42094209
}
42104210
if matches {
4211-
matched_txn.insert(tx.txid());
4211+
matched_txn.insert(tx.compute_txid());
42124212
}
42134213
matches
42144214
}).map(|(_, tx)| *tx).collect()
@@ -4362,12 +4362,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
43624362
if ($holder_tx && revocation_sig_claim) ||
43634363
(outbound_htlc && !$source_avail && (accepted_preimage_claim || offered_preimage_claim)) {
43644364
log_error!(logger, "Input spending {} ({}:{}) in {} resolves {} HTLC with payment hash {} with {}!",
4365-
$tx_info, input.previous_output.txid, input.previous_output.vout, tx.txid(),
4365+
$tx_info, input.previous_output.txid, input.previous_output.vout, tx.compute_txid(),
43664366
if outbound_htlc { "outbound" } else { "inbound" }, &$htlc.payment_hash,
43674367
if revocation_sig_claim { "revocation sig" } else { "preimage claim after we'd passed the HTLC resolution back. We can likely claim the HTLC output with a revocation claim" });
43684368
} else {
43694369
log_info!(logger, "Input spending {} ({}:{}) in {} resolves {} HTLC with payment hash {} with {}",
4370-
$tx_info, input.previous_output.txid, input.previous_output.vout, tx.txid(),
4370+
$tx_info, input.previous_output.txid, input.previous_output.vout, tx.compute_txid(),
43714371
if outbound_htlc { "outbound" } else { "inbound" }, &$htlc.payment_hash,
43724372
if revocation_sig_claim { "revocation sig" } else if accepted_preimage_claim || offered_preimage_claim { "preimage" } else { "timeout" });
43734373
}
@@ -4414,7 +4414,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
44144414
log_claim!($tx_info, $holder_tx, htlc_output, false);
44154415
let outbound_htlc = $holder_tx == htlc_output.offered;
44164416
self.onchain_events_awaiting_threshold_conf.push(OnchainEventEntry {
4417-
txid: tx.txid(), height, block_hash: Some(*block_hash), transaction: Some(tx.clone()),
4417+
txid: tx.compute_txid(), height, block_hash: Some(*block_hash), transaction: Some(tx.clone()),
44184418
event: OnchainEvent::HTLCSpendConfirmation {
44194419
commitment_tx_output_idx: input.previous_output.vout,
44204420
preimage: if accepted_preimage_claim || offered_preimage_claim {
@@ -4456,7 +4456,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
44564456
if !self.pending_monitor_events.iter().any(
44574457
|update| if let &MonitorEvent::HTLCEvent(ref upd) = update { upd.source == source } else { false }) {
44584458
self.onchain_events_awaiting_threshold_conf.push(OnchainEventEntry {
4459-
txid: tx.txid(),
4459+
txid: tx.compute_txid(),
44604460
height,
44614461
block_hash: Some(*block_hash),
44624462
transaction: Some(tx.clone()),
@@ -4479,7 +4479,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
44794479
upd.source == source
44804480
} else { false }) {
44814481
self.onchain_events_awaiting_threshold_conf.push(OnchainEventEntry {
4482-
txid: tx.txid(),
4482+
txid: tx.compute_txid(),
44834483
transaction: Some(tx.clone()),
44844484
height,
44854485
block_hash: Some(*block_hash),
@@ -4507,7 +4507,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
45074507
}
45084508
});
45094509
let entry = OnchainEventEntry {
4510-
txid: tx.txid(),
4510+
txid: tx.compute_txid(),
45114511
transaction: Some(tx.clone()),
45124512
height,
45134513
block_hash: Some(*block_hash),
@@ -4529,15 +4529,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
45294529
for (i, outp) in tx.output.iter().enumerate() {
45304530
if outp.script_pubkey == self.destination_script {
45314531
spendable_outputs.push(SpendableOutputDescriptor::StaticOutput {
4532-
outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
4532+
outpoint: OutPoint { txid: tx.compute_txid(), index: i as u16 },
45334533
output: outp.clone(),
45344534
channel_keys_id: Some(self.channel_keys_id),
45354535
});
45364536
}
45374537
if let Some(ref broadcasted_holder_revokable_script) = self.broadcasted_holder_revokable_script {
45384538
if broadcasted_holder_revokable_script.0 == outp.script_pubkey {
45394539
spendable_outputs.push(SpendableOutputDescriptor::DelayedPaymentOutput(DelayedPaymentOutputDescriptor {
4540-
outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
4540+
outpoint: OutPoint { txid: tx.compute_txid(), index: i as u16 },
45414541
per_commitment_point: broadcasted_holder_revokable_script.1,
45424542
to_self_delay: self.on_holder_tx_csv,
45434543
output: outp.clone(),
@@ -4550,7 +4550,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
45504550
}
45514551
if self.counterparty_payment_script == outp.script_pubkey {
45524552
spendable_outputs.push(SpendableOutputDescriptor::StaticPaymentOutput(StaticPaymentOutputDescriptor {
4553-
outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
4553+
outpoint: OutPoint { txid: tx.compute_txid(), index: i as u16 },
45544554
output: outp.clone(),
45554555
channel_keys_id: self.channel_keys_id,
45564556
channel_value_satoshis: self.channel_value_satoshis,
@@ -4559,7 +4559,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
45594559
}
45604560
if self.shutdown_script.as_ref() == Some(&outp.script_pubkey) {
45614561
spendable_outputs.push(SpendableOutputDescriptor::StaticOutput {
4562-
outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
4562+
outpoint: OutPoint { txid: tx.compute_txid(), index: i as u16 },
45634563
output: outp.clone(),
45644564
channel_keys_id: Some(self.channel_keys_id),
45654565
});
@@ -4575,7 +4575,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
45754575
) where L::Target: Logger {
45764576
for spendable_output in self.get_spendable_outputs(tx) {
45774577
let entry = OnchainEventEntry {
4578-
txid: tx.txid(),
4578+
txid: tx.compute_txid(),
45794579
transaction: Some(tx.clone()),
45804580
height,
45814581
block_hash: Some(*block_hash),
@@ -5068,7 +5068,7 @@ mod tests {
50685068
assert!(txn_broadcasted.len() >= 2);
50695069
let htlc_txn = txn_broadcasted.iter().filter(|tx| {
50705070
assert_eq!(tx.input.len(), 1);
5071-
tx.input[0].previous_output.txid == broadcast_tx.txid()
5071+
tx.input[0].previous_output.txid == broadcast_tx.compute_txid()
50725072
}).collect::<Vec<_>>();
50735073
assert_eq!(htlc_txn.len(), 2);
50745074
check_spends!(htlc_txn[0], broadcast_tx);

0 commit comments

Comments
 (0)