@@ -1188,6 +1188,9 @@ pub(crate) struct ShutdownResult {
1188
1188
pub(crate) unbroadcasted_funding_tx: Option<Transaction>,
1189
1189
pub(crate) channel_funding_txo: Option<OutPoint>,
1190
1190
pub(crate) last_local_balance_msat: u64,
1191
+ /// If a splice was in progress when the channel was shut down, this contains
1192
+ /// the splice funding information for emitting a SpliceFailed event.
1193
+ pub(crate) splice_funding_failed: Option<SpliceFundingFailed>,
1191
1194
}
1192
1195
1193
1196
/// Tracks the transaction number, along with current and next commitment points.
@@ -6043,6 +6046,7 @@ where
6043
6046
is_manual_broadcast: self.is_manual_broadcast,
6044
6047
channel_funding_txo: funding.get_funding_txo(),
6045
6048
last_local_balance_msat: funding.value_to_self_msat,
6049
+ splice_funding_failed: None,
6046
6050
}
6047
6051
}
6048
6052
@@ -6846,7 +6850,38 @@ where
6846
6850
}
6847
6851
6848
6852
pub fn force_shutdown(&mut self, closure_reason: ClosureReason) -> ShutdownResult {
6849
- self.context.force_shutdown(&self.funding, closure_reason)
6853
+ // Capture splice funding failed information if we have an active splice negotiation
6854
+ let splice_funding_failed = self.pending_splice.as_mut()
6855
+ .and_then(|pending_splice| pending_splice.funding_negotiation.take())
6856
+ .filter(|funding_negotiation| funding_negotiation.is_initiator())
6857
+ .map(|funding_negotiation| {
6858
+ // Create SpliceFundingFailed for any active splice negotiation during shutdown
6859
+ let (funding_txo, channel_type) = match &funding_negotiation {
6860
+ FundingNegotiation::AwaitingAck { .. } => {
6861
+ (None, None)
6862
+ },
6863
+ FundingNegotiation::ConstructingTransaction { funding, .. } => {
6864
+ (funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()), Some(funding.get_channel_type().clone()))
6865
+ },
6866
+ FundingNegotiation::AwaitingSignatures { funding, .. } => {
6867
+ (funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()), Some(funding.get_channel_type().clone()))
6868
+ },
6869
+ };
6870
+
6871
+ SpliceFundingFailed {
6872
+ channel_id: self.context.channel_id,
6873
+ counterparty_node_id: self.context.counterparty_node_id,
6874
+ user_channel_id: self.context.user_id,
6875
+ funding_txo,
6876
+ channel_type,
6877
+ contributed_inputs: Vec::new(),
6878
+ contributed_outputs: Vec::new(),
6879
+ }
6880
+ });
6881
+
6882
+ let mut shutdown_result = self.context.force_shutdown(&self.funding, closure_reason);
6883
+ shutdown_result.splice_funding_failed = splice_funding_failed;
6884
+ shutdown_result
6850
6885
}
6851
6886
6852
6887
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
@@ -10284,6 +10319,7 @@ where
10284
10319
is_manual_broadcast: self.context.is_manual_broadcast,
10285
10320
channel_funding_txo: self.funding.get_funding_txo(),
10286
10321
last_local_balance_msat: self.funding.value_to_self_msat,
10322
+ splice_funding_failed: None,
10287
10323
}
10288
10324
}
10289
10325
0 commit comments