From 1e285cb417fe43503c96533508f1127fba26d99b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 27 Aug 2024 19:17:06 +0000 Subject: [PATCH] Only generate an `Event::DiscardFunding` when we need to 5e874c3dc9cf1606a3cbbccab3a0d25089a97280 changed `Event::DiscardFunding` to not include a dummy transaction when we were funded without a full funding tx, but in doing so started generating `DiscardFunding` events on every channel closure rather than only when there's actually still a pending funding broadcast. This restores the previous behavior to only generate the event when we should actually discard the funding tx. --- lightning/src/ln/channelmanager.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index b14369c43..258bc0661 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -3547,12 +3547,15 @@ where channel_funding_txo: shutdown_res.channel_funding_txo, }, None)); - let funding_info = if is_manual_broadcast { - shutdown_res.channel_funding_txo.map(|outpoint| FundingInfo::OutPoint{ outpoint }) - } else { - shutdown_res.unbroadcasted_funding_tx.map(|transaction| FundingInfo::Tx{ transaction }) - }; - if let Some(funding_info) = funding_info { + if let Some(transaction) = shutdown_res.unbroadcasted_funding_tx { + let funding_info = if is_manual_broadcast { + FundingInfo::OutPoint { + outpoint: shutdown_res.channel_funding_txo + .expect("We had an unbroadcasted funding tx, so should also have had a funding outpoint"), + } + } else { + FundingInfo::Tx{ transaction } + }; pending_events.push_back((events::Event::DiscardFunding { channel_id: shutdown_res.channel_id, funding_info }, None)); -- 2.39.5