@@ -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.
@@ -2667,6 +2670,15 @@ pub(crate) struct SpliceInstructions {
2667
2670
locktime: u32,
2668
2671
}
2669
2672
2673
+ impl SpliceInstructions {
2674
+ fn into_contributed_inputs_and_outputs(self) -> (Vec<bitcoin::OutPoint>, Vec<TxOut>) {
2675
+ (
2676
+ self.our_funding_inputs.into_iter().map(|input| input.utxo.outpoint).collect(),
2677
+ self.our_funding_outputs,
2678
+ )
2679
+ }
2680
+ }
2681
+
2670
2682
impl_writeable_tlv_based!(SpliceInstructions, {
2671
2683
(1, adjusted_funding_contribution, required),
2672
2684
(3, our_funding_inputs, required_vec),
@@ -6021,6 +6033,7 @@ where
6021
6033
is_manual_broadcast: self.is_manual_broadcast,
6022
6034
channel_funding_txo: funding.get_funding_txo(),
6023
6035
last_local_balance_msat: funding.value_to_self_msat,
6036
+ splice_funding_failed: None,
6024
6037
}
6025
6038
}
6026
6039
@@ -6805,7 +6818,35 @@ where
6805
6818
}
6806
6819
6807
6820
pub fn force_shutdown(&mut self, closure_reason: ClosureReason) -> ShutdownResult {
6808
- self.context.force_shutdown(&self.funding, closure_reason)
6821
+ let splice_funding_failed =
6822
+ if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) {
6823
+ self.reset_pending_splice_state().or_else(|| {
6824
+ self.quiescent_action.take().and_then(|quiescent_action| match quiescent_action
6825
+ {
6826
+ QuiescentAction::Splice(instructions) => {
6827
+ let (inputs, outputs) =
6828
+ instructions.into_contributed_inputs_and_outputs();
6829
+ Some(SpliceFundingFailed {
6830
+ funding_txo: None,
6831
+ channel_type: None,
6832
+ contributed_inputs: inputs,
6833
+ contributed_outputs: outputs,
6834
+ })
6835
+ },
6836
+ #[cfg(any(test, fuzzing))]
6837
+ _ => {
6838
+ self.quiescent_action = Some(quiescent_action);
6839
+ None
6840
+ },
6841
+ })
6842
+ })
6843
+ } else {
6844
+ None
6845
+ };
6846
+
6847
+ let mut shutdown_result = self.context.force_shutdown(&self.funding, closure_reason);
6848
+ shutdown_result.splice_funding_failed = splice_funding_failed;
6849
+ shutdown_result
6809
6850
}
6810
6851
6811
6852
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
@@ -10335,6 +10376,7 @@ where
10335
10376
is_manual_broadcast: self.context.is_manual_broadcast,
10336
10377
channel_funding_txo: self.funding.get_funding_txo(),
10337
10378
last_local_balance_msat: self.funding.value_to_self_msat,
10379
+ splice_funding_failed: None,
10338
10380
}
10339
10381
}
10340
10382
0 commit comments