@@ -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.
@@ -2669,6 +2672,15 @@ pub(crate) struct SpliceInstructions {
2669
2672
locktime: u32,
2670
2673
}
2671
2674
2675
+ impl SpliceInstructions {
2676
+ fn into_contributed_inputs_and_outputs(self) -> (Vec<bitcoin::OutPoint>, Vec<TxOut>) {
2677
+ (
2678
+ self.our_funding_inputs.into_iter().map(|input| input.utxo.outpoint).collect(),
2679
+ self.our_funding_outputs,
2680
+ )
2681
+ }
2682
+ }
2683
+
2672
2684
impl_writeable_tlv_based!(SpliceInstructions, {
2673
2685
(1, adjusted_funding_contribution, required),
2674
2686
(3, our_funding_inputs, required_vec),
@@ -6023,6 +6035,7 @@ where
6023
6035
is_manual_broadcast: self.is_manual_broadcast,
6024
6036
channel_funding_txo: funding.get_funding_txo(),
6025
6037
last_local_balance_msat: funding.value_to_self_msat,
6038
+ splice_funding_failed: None,
6026
6039
}
6027
6040
}
6028
6041
@@ -6795,7 +6808,35 @@ where
6795
6808
}
6796
6809
6797
6810
pub fn force_shutdown(&mut self, closure_reason: ClosureReason) -> ShutdownResult {
6798
- self.context.force_shutdown(&self.funding, closure_reason)
6811
+ let splice_funding_failed =
6812
+ if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) {
6813
+ self.reset_pending_splice_state().or_else(|| {
6814
+ self.quiescent_action.take().and_then(|quiescent_action| match quiescent_action
6815
+ {
6816
+ QuiescentAction::Splice(instructions) => {
6817
+ let (inputs, outputs) =
6818
+ instructions.into_contributed_inputs_and_outputs();
6819
+ Some(SpliceFundingFailed {
6820
+ funding_txo: None,
6821
+ channel_type: None,
6822
+ contributed_inputs: inputs,
6823
+ contributed_outputs: outputs,
6824
+ })
6825
+ },
6826
+ #[cfg(any(test, fuzzing))]
6827
+ _ => {
6828
+ self.quiescent_action = Some(quiescent_action);
6829
+ None
6830
+ },
6831
+ })
6832
+ })
6833
+ } else {
6834
+ None
6835
+ };
6836
+
6837
+ let mut shutdown_result = self.context.force_shutdown(&self.funding, closure_reason);
6838
+ shutdown_result.splice_funding_failed = splice_funding_failed;
6839
+ shutdown_result
6799
6840
}
6800
6841
6801
6842
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
@@ -10331,6 +10372,7 @@ where
10331
10372
is_manual_broadcast: self.context.is_manual_broadcast,
10332
10373
channel_funding_txo: self.funding.get_funding_txo(),
10333
10374
last_local_balance_msat: self.funding.value_to_self_msat,
10375
+ splice_funding_failed: None,
10334
10376
}
10335
10377
}
10336
10378
0 commit comments