]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Only generate an `Event::DiscardFunding` when we need to
authorMatt Corallo <git@bluematt.me>
Tue, 27 Aug 2024 19:17:06 +0000 (19:17 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 27 Aug 2024 19:31:25 +0000 (19:31 +0000)
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

index b14369c432a42273e168220c2f6617b339994bee..258bc066125fc15505423f78de164dacfd52e753 100644 (file)
@@ -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));