Skip to content

Commit 9c08c86

Browse files
committed
Rework the broadcast check, review comments
1 parent 789348b commit 9c08c86

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lightning/src/ln/channel.rs

+8-13
Original file line numberDiff line numberDiff line change
@@ -5481,24 +5481,19 @@ impl<SP: Deref> Channel<SP> where
54815481
// If we're past (or at) the AwaitingChannelReady stage on an outbound channel, try to
54825482
// (re-)broadcast the funding transaction as we may have declined to broadcast it when we
54835483
// 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 {
54855486
if self.context.is_outbound() &&
54865487
(matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) ||
54875488
matches!(self.context.channel_state, ChannelState::ChannelReady(_)))
54885489
{
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 {
54975494
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());
55025497
}
55035498
}
55045499
}

0 commit comments

Comments
 (0)