@@ -5481,24 +5481,19 @@ impl<SP: Deref> Channel<SP> where
5481
5481
// If we're past (or at) the AwaitingChannelReady stage on an outbound channel, try to
5482
5482
// (re-)broadcast the funding transaction as we may have declined to broadcast it when we
5483
5483
// first received the funding_signed.
5484
- let mut funding_broadcastable =
5484
+ let mut funding_broadcastable = None;
5485
+ if let Some(funding_transaction) = &self.context.funding_transaction {
5485
5486
if self.context.is_outbound() &&
5486
5487
(matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) ||
5487
5488
matches!(self.context.channel_state, ChannelState::ChannelReady(_)))
5488
5489
{
5489
- // Take the funding transaction, do not clear the field
5490
- self.context.funding_transaction.clone()
5491
- } else { None };
5492
- // That said, if the funding transaction is already confirmed,
5493
- // don't bother re-broadcasting the confirmed funding tx.
5494
- if funding_broadcastable.is_some() {
5495
- if let Some(height) = self.context.get_funding_tx_confirmation_height() {
5496
- if let Some(block) = self.context.get_funding_tx_confirmed_in() {
5490
+ // Broadcast only if not yet confirmed
5491
+ if self.context.get_funding_tx_confirmation_height().is_none() || self.context.get_funding_tx_confirmed_in().is_none() {
5492
+ funding_broadcastable = Some(funding_transaction.clone())
5493
+ } else {
5497
5494
log_debug!(logger,
5498
- "Not rebroadcasting funding tx, as it's already confirmed, height: {} block: {} txid: {}",
5499
- height, block, funding_broadcastable.unwrap().txid()
5500
- );
5501
- funding_broadcastable = None;
5495
+ "Not rebroadcasting funding tx, already confirmed, height: {} txid: {}",
5496
+ self.context.get_funding_tx_confirmation_height().unwrap_or_default(), funding_transaction.compute_txid());
5502
5497
}
5503
5498
}
5504
5499
}
0 commit comments