@@ -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.
@@ -2664,6 +2667,15 @@ pub(crate) struct SpliceInstructions {
2664
2667
locktime: u32,
2665
2668
}
2666
2669
2670
+ impl SpliceInstructions {
2671
+ fn into_contributed_inputs_and_outputs(self) -> (Vec<bitcoin::OutPoint>, Vec<TxOut>) {
2672
+ (
2673
+ self.our_funding_inputs.into_iter().map(|input| input.utxo.outpoint).collect(),
2674
+ self.our_funding_outputs,
2675
+ )
2676
+ }
2677
+ }
2678
+
2667
2679
impl_writeable_tlv_based!(SpliceInstructions, {
2668
2680
(1, adjusted_funding_contribution, required),
2669
2681
(3, our_funding_inputs, required_vec),
@@ -6018,6 +6030,7 @@ where
6018
6030
is_manual_broadcast: self.is_manual_broadcast,
6019
6031
channel_funding_txo: funding.get_funding_txo(),
6020
6032
last_local_balance_msat: funding.value_to_self_msat,
6033
+ splice_funding_failed: None,
6021
6034
}
6022
6035
}
6023
6036
@@ -6787,7 +6800,42 @@ where
6787
6800
}
6788
6801
6789
6802
pub fn force_shutdown(&mut self, closure_reason: ClosureReason) -> ShutdownResult {
6790
- self.context.force_shutdown(&self.funding, closure_reason)
6803
+ let splice_funding_failed = self
6804
+ .pending_splice
6805
+ .as_mut()
6806
+ .and_then(|pending_splice| pending_splice.funding_negotiation.take())
6807
+ .filter(|funding_negotiation| funding_negotiation.is_initiator())
6808
+ .map(|_funding_negotiation| {
6809
+ // FIXME: Populte after #4120 is merged
6810
+ SpliceFundingFailed {
6811
+ funding_txo: todo!(),
6812
+ channel_type: todo!(),
6813
+ contributed_inputs: todo!(),
6814
+ contributed_outputs: todo!(),
6815
+ }
6816
+ })
6817
+ .or_else(|| {
6818
+ self.quiescent_action.take().and_then(|quiescent_action| match quiescent_action {
6819
+ QuiescentAction::Splice(instructions) => {
6820
+ let (inputs, outputs) = instructions.into_contributed_inputs_and_outputs();
6821
+ Some(SpliceFundingFailed {
6822
+ funding_txo: None,
6823
+ channel_type: None,
6824
+ contributed_inputs: inputs,
6825
+ contributed_outputs: outputs,
6826
+ })
6827
+ },
6828
+ #[cfg(any(test, fuzzing))]
6829
+ _ => {
6830
+ self.quiescent_action = Some(quiescent_action);
6831
+ None
6832
+ },
6833
+ })
6834
+ });
6835
+
6836
+ let mut shutdown_result = self.context.force_shutdown(&self.funding, closure_reason);
6837
+ shutdown_result.splice_funding_failed = splice_funding_failed;
6838
+ shutdown_result
6791
6839
}
6792
6840
6793
6841
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
@@ -10222,6 +10270,7 @@ where
10222
10270
is_manual_broadcast: self.context.is_manual_broadcast,
10223
10271
channel_funding_txo: self.funding.get_funding_txo(),
10224
10272
last_local_balance_msat: self.funding.value_to_self_msat,
10273
+ splice_funding_failed: None,
10225
10274
}
10226
10275
}
10227
10276
0 commit comments