Skip to content

Commit 9e1853f

Browse files
authored
Merge pull request #3380 from optout21/channel-funding-tx-simple
[Splicing] Preserve funding_transaction for the later lifecycle of the channel, simple solution
2 parents bba3071 + 5577a88 commit 9e1853f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lightning/src/ln/channel.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -5495,17 +5495,17 @@ impl<SP: Deref> Channel<SP> where
54955495
// If we're past (or at) the AwaitingChannelReady stage on an outbound channel, try to
54965496
// (re-)broadcast the funding transaction as we may have declined to broadcast it when we
54975497
// first received the funding_signed.
5498-
let mut funding_broadcastable =
5498+
let mut funding_broadcastable = None;
5499+
if let Some(funding_transaction) = &self.context.funding_transaction {
54995500
if self.context.is_outbound() &&
55005501
(matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) ||
55015502
matches!(self.context.channel_state, ChannelState::ChannelReady(_)))
55025503
{
5503-
self.context.funding_transaction.take()
5504-
} else { None };
5505-
// That said, if the funding transaction is already confirmed (ie we're active with a
5506-
// minimum_depth over 0) don't bother re-broadcasting the confirmed funding tx.
5507-
if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) && self.context.minimum_depth != Some(0) {
5508-
funding_broadcastable = None;
5504+
// Broadcast only if not yet confirmed
5505+
if self.context.get_funding_tx_confirmation_height().is_none() {
5506+
funding_broadcastable = Some(funding_transaction.clone())
5507+
}
5508+
}
55095509
}
55105510

55115511
// 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 {
79077907
self.context.minimum_depth = Some(COINBASE_MATURITY);
79087908
}
79097909

7910+
debug_assert!(self.context.funding_transaction.is_none());
79107911
self.context.funding_transaction = Some(funding_transaction);
79117912
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
79127913

0 commit comments

Comments
 (0)