Merge pull request #3380 from optout21/channel-funding-tx-simple

[Splicing] Preserve funding_transaction for the later lifecycle of the channel, simple solution
This commit is contained in:
Matt Corallo 2024-10-29 14:57:17 +00:00 committed by GitHub
commit 9e1853f9c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5495,17 +5495,17 @@ impl<SP: Deref> Channel<SP> where
// If we're past (or at) the AwaitingChannelReady stage on an outbound channel, try to // 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 // (re-)broadcast the funding transaction as we may have declined to broadcast it when we
// first received the funding_signed. // 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() && 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::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) ||
matches!(self.context.channel_state, ChannelState::ChannelReady(_))) matches!(self.context.channel_state, ChannelState::ChannelReady(_)))
{ {
self.context.funding_transaction.take() // Broadcast only if not yet confirmed
} else { None }; if self.context.get_funding_tx_confirmation_height().is_none() {
// That said, if the funding transaction is already confirmed (ie we're active with a funding_broadcastable = Some(funding_transaction.clone())
// 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;
} }
// We will never broadcast the funding transaction when we're in MonitorUpdateInProgress // We will never broadcast the funding transaction when we're in MonitorUpdateInProgress
@ -7907,6 +7907,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
self.context.minimum_depth = Some(COINBASE_MATURITY); self.context.minimum_depth = Some(COINBASE_MATURITY);
} }
debug_assert!(self.context.funding_transaction.is_none());
self.context.funding_transaction = Some(funding_transaction); self.context.funding_transaction = Some(funding_transaction);
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding); self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);