From: optout <13562139+optout21@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:29:47 +0000 (+0100) Subject: Preserve funding_transaction for the later lifecycle of the channel, simple solution X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=5577a88ac019662905629acacb295d7745783d39;p=rust-lightning Preserve funding_transaction for the later lifecycle of the channel, simple solution --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 42458e476..a62ba97f6 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -5481,17 +5481,17 @@ impl Channel where // If we're past (or at) the AwaitingChannelReady stage on an outbound channel, try to // (re-)broadcast the funding transaction as we may have declined to broadcast it when we // first received the funding_signed. - let mut funding_broadcastable = + let mut funding_broadcastable = None; + if let Some(funding_transaction) = &self.context.funding_transaction { if self.context.is_outbound() && (matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) || matches!(self.context.channel_state, ChannelState::ChannelReady(_))) { - self.context.funding_transaction.take() - } else { None }; - // That said, if the funding transaction is already confirmed (ie we're active with a - // minimum_depth over 0) don't bother re-broadcasting the confirmed funding tx. - if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) && self.context.minimum_depth != Some(0) { - funding_broadcastable = None; + // Broadcast only if not yet confirmed + if self.context.get_funding_tx_confirmation_height().is_none() { + funding_broadcastable = Some(funding_transaction.clone()) + } + } } // We will never broadcast the funding transaction when we're in MonitorUpdateInProgress @@ -7893,6 +7893,7 @@ impl OutboundV1Channel where SP::Target: SignerProvider { self.context.minimum_depth = Some(COINBASE_MATURITY); } + debug_assert!(self.context.funding_transaction.is_none()); self.context.funding_transaction = Some(funding_transaction); self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);