Skip to content

Commit 2e77392

Browse files
committed
Switch to take_if in two places
.. addressing the TODOs there now that we can.
1 parent 3064cbc commit 2e77392

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5338,18 +5338,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
53385338
//- maturing spendable output has transaction paying us has been disconnected
53395339
self.onchain_events_awaiting_threshold_conf.retain(|ref entry| entry.height < height);
53405340

5341-
// TODO: Replace with `take_if` once our MSRV is >= 1.80.
5342-
if let Some((_, conf_height)) = self.alternative_funding_confirmed.as_ref() {
5343-
if *conf_height == height {
5344-
self.alternative_funding_confirmed.take();
5345-
if self.holder_tx_signed {
5346-
// Cancel any previous claims that are no longer valid as they stemmed from a
5347-
// different funding transaction. We'll wait until we see a funding transaction
5348-
// confirm again before attempting to broadcast the new valid holder commitment.
5349-
let new_holder_commitment_txid =
5350-
self.funding.current_holder_commitment_tx.trust().txid();
5351-
self.cancel_prev_commitment_claims(&logger, &new_holder_commitment_txid);
5352-
}
5341+
if self.alternative_funding_confirmed.take_if(|(_, conf_height)| *conf_height == height).is_some() {
5342+
if self.holder_tx_signed {
5343+
// Cancel any previous claims that are no longer valid as they stemmed from a
5344+
// different funding transaction. We'll wait until we see a funding transaction
5345+
// confirm again before attempting to broadcast the new valid holder commitment.
5346+
let new_holder_commitment_txid =
5347+
self.funding.current_holder_commitment_tx.trust().txid();
5348+
self.cancel_prev_commitment_claims(&logger, &new_holder_commitment_txid);
53535349
}
53545350
}
53555351

@@ -5392,18 +5388,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
53925388

53935389
debug_assert!(!self.onchain_events_awaiting_threshold_conf.iter().any(|ref entry| entry.txid == *txid));
53945390

5395-
// TODO: Replace with `take_if` once our MSRV is >= 1.80.
5396-
if let Some((alternative_funding_txid, _)) = self.alternative_funding_confirmed.as_ref() {
5397-
if alternative_funding_txid == txid {
5398-
self.alternative_funding_confirmed.take();
5399-
if self.holder_tx_signed {
5400-
// Cancel any previous claims that are no longer valid as they stemmed from a
5401-
// different funding transaction. We'll wait until we see a funding transaction
5402-
// confirm again before attempting to broadcast the new valid holder commitment.
5403-
let new_holder_commitment_txid =
5404-
self.funding.current_holder_commitment_tx.trust().txid();
5405-
self.cancel_prev_commitment_claims(&logger, &new_holder_commitment_txid);
5406-
}
5391+
if self.alternative_funding_confirmed.take_if(|(alternative_funding_txid, _)| alternative_funding_txid == txid).is_some() {
5392+
if self.holder_tx_signed {
5393+
// Cancel any previous claims that are no longer valid as they stemmed from a
5394+
// different funding transaction. We'll wait until we see a funding transaction
5395+
// confirm again before attempting to broadcast the new valid holder commitment.
5396+
let new_holder_commitment_txid =
5397+
self.funding.current_holder_commitment_tx.trust().txid();
5398+
self.cancel_prev_commitment_claims(&logger, &new_holder_commitment_txid);
54075399
}
54085400
}
54095401

0 commit comments

Comments
 (0)