@@ -1222,6 +1222,9 @@ pub(crate) struct ShutdownResult {
1222
1222
pub(crate) unbroadcasted_funding_tx: Option<Transaction>,
1223
1223
pub(crate) channel_funding_txo: Option<OutPoint>,
1224
1224
pub(crate) last_local_balance_msat: u64,
1225
+ /// If a splice was in progress when the channel was shut down, this contains
1226
+ /// the splice funding information for emitting a SpliceFailed event.
1227
+ pub(crate) splice_funding_failed: Option<SpliceFundingFailed>,
1225
1228
}
1226
1229
1227
1230
/// Tracks the transaction number, along with current and next commitment points.
@@ -6092,6 +6095,7 @@ where
6092
6095
is_manual_broadcast: self.is_manual_broadcast,
6093
6096
channel_funding_txo: funding.get_funding_txo(),
6094
6097
last_local_balance_msat: funding.value_to_self_msat,
6098
+ splice_funding_failed: None,
6095
6099
}
6096
6100
}
6097
6101
@@ -6899,7 +6903,37 @@ where
6899
6903
}
6900
6904
6901
6905
pub fn force_shutdown(&mut self, closure_reason: ClosureReason) -> ShutdownResult {
6902
- self.context.force_shutdown(&self.funding, closure_reason)
6906
+ // Capture splice funding failed information if we have an active splice negotiation
6907
+ let splice_funding_failed = self.pending_splice.as_mut()
6908
+ .and_then(|pending_splice| pending_splice.funding_negotiation.take())
6909
+ .map(|funding_negotiation| {
6910
+ // Create SpliceFundingFailed for any active splice negotiation during shutdown
6911
+ let (funding_txo, channel_type) = match &funding_negotiation {
6912
+ FundingNegotiation::AwaitingAck { .. } => {
6913
+ (None, None)
6914
+ },
6915
+ FundingNegotiation::ConstructingTransaction { funding, .. } => {
6916
+ (funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()), Some(funding.get_channel_type().clone()))
6917
+ },
6918
+ FundingNegotiation::AwaitingSignatures { funding, .. } => {
6919
+ (funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()), Some(funding.get_channel_type().clone()))
6920
+ },
6921
+ };
6922
+
6923
+ SpliceFundingFailed {
6924
+ channel_id: self.context.channel_id,
6925
+ counterparty_node_id: self.context.counterparty_node_id,
6926
+ user_channel_id: self.context.user_id,
6927
+ funding_txo,
6928
+ channel_type,
6929
+ contributed_inputs: Vec::new(),
6930
+ contributed_outputs: Vec::new(),
6931
+ }
6932
+ });
6933
+
6934
+ let mut shutdown_result = self.context.force_shutdown(&self.funding, closure_reason);
6935
+ shutdown_result.splice_funding_failed = splice_funding_failed;
6936
+ shutdown_result
6903
6937
}
6904
6938
6905
6939
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
@@ -10295,6 +10329,7 @@ where
10295
10329
is_manual_broadcast: self.context.is_manual_broadcast,
10296
10330
channel_funding_txo: self.funding.get_funding_txo(),
10297
10331
last_local_balance_msat: self.funding.value_to_self_msat,
10332
+ splice_funding_failed: None,
10298
10333
}
10299
10334
}
10300
10335
0 commit comments