Only generate an Event::DiscardFunding when we need to

5e874c3dc9 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.
This commit is contained in:
Matt Corallo 2024-08-27 19:17:06 +00:00
parent 5e62df7f20
commit 1e285cb417

View file

@ -3547,12 +3547,15 @@ where
channel_funding_txo: shutdown_res.channel_funding_txo, channel_funding_txo: shutdown_res.channel_funding_txo,
}, None)); }, None));
if let Some(transaction) = shutdown_res.unbroadcasted_funding_tx {
let funding_info = if is_manual_broadcast { let funding_info = if is_manual_broadcast {
shutdown_res.channel_funding_txo.map(|outpoint| FundingInfo::OutPoint{ outpoint }) FundingInfo::OutPoint {
outpoint: shutdown_res.channel_funding_txo
.expect("We had an unbroadcasted funding tx, so should also have had a funding outpoint"),
}
} else { } else {
shutdown_res.unbroadcasted_funding_tx.map(|transaction| FundingInfo::Tx{ transaction }) FundingInfo::Tx{ transaction }
}; };
if let Some(funding_info) = funding_info {
pending_events.push_back((events::Event::DiscardFunding { pending_events.push_back((events::Event::DiscardFunding {
channel_id: shutdown_res.channel_id, funding_info channel_id: shutdown_res.channel_id, funding_info
}, None)); }, None));