@@ -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,30 @@ 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 = self
6812
+ .reset_pending_splice_state()
6813
+ .or_else(|| {
6814
+ self.quiescent_action.take().and_then(|quiescent_action| match quiescent_action {
6815
+ QuiescentAction::Splice(instructions) => {
6816
+ let (inputs, outputs) = instructions.into_contributed_inputs_and_outputs();
6817
+ Some(SpliceFundingFailed {
6818
+ funding_txo: None,
6819
+ channel_type: None,
6820
+ contributed_inputs: inputs,
6821
+ contributed_outputs: outputs,
6822
+ })
6823
+ },
6824
+ #[cfg(any(test, fuzzing))]
6825
+ _ => {
6826
+ self.quiescent_action = Some(quiescent_action);
6827
+ None
6828
+ },
6829
+ })
6830
+ });
6831
+
6832
+ let mut shutdown_result = self.context.force_shutdown(&self.funding, closure_reason);
6833
+ shutdown_result.splice_funding_failed = splice_funding_failed;
6834
+ shutdown_result
6799
6835
}
6800
6836
6801
6837
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
@@ -10331,6 +10367,7 @@ where
10331
10367
is_manual_broadcast: self.context.is_manual_broadcast,
10332
10368
channel_funding_txo: self.funding.get_funding_txo(),
10333
10369
last_local_balance_msat: self.funding.value_to_self_msat,
10370
+ splice_funding_failed: None,
10334
10371
}
10335
10372
}
10336
10373
0 commit comments