@@ -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.
@@ -2676,6 +2679,15 @@ pub(crate) struct SpliceInstructions {
2676
2679
locktime: u32,
2677
2680
}
2678
2681
2682
+ impl SpliceInstructions {
2683
+ fn into_contributed_inputs_and_outputs(self) -> (Vec<bitcoin::OutPoint>, Vec<TxOut>) {
2684
+ (
2685
+ self.our_funding_inputs.into_iter().map(|input| input.utxo.outpoint).collect(),
2686
+ self.our_funding_outputs,
2687
+ )
2688
+ }
2689
+ }
2690
+
2679
2691
impl_writeable_tlv_based!(SpliceInstructions, {
2680
2692
(1, adjusted_funding_contribution, required),
2681
2693
(3, our_funding_inputs, required_vec),
@@ -6030,6 +6042,7 @@ where
6030
6042
is_manual_broadcast: self.is_manual_broadcast,
6031
6043
channel_funding_txo: funding.get_funding_txo(),
6032
6044
last_local_balance_msat: funding.value_to_self_msat,
6045
+ splice_funding_failed: None,
6033
6046
}
6034
6047
}
6035
6048
@@ -6823,7 +6836,42 @@ where
6823
6836
}
6824
6837
6825
6838
pub fn force_shutdown(&mut self, closure_reason: ClosureReason) -> ShutdownResult {
6826
- self.context.force_shutdown(&self.funding, closure_reason)
6839
+ let splice_funding_failed = self
6840
+ .pending_splice
6841
+ .as_mut()
6842
+ .and_then(|pending_splice| pending_splice.funding_negotiation.take())
6843
+ .filter(|funding_negotiation| funding_negotiation.is_initiator())
6844
+ .map(|_funding_negotiation| {
6845
+ // FIXME: Populte after #4120 is merged
6846
+ SpliceFundingFailed {
6847
+ funding_txo: todo!(),
6848
+ channel_type: todo!(),
6849
+ contributed_inputs: todo!(),
6850
+ contributed_outputs: todo!(),
6851
+ }
6852
+ })
6853
+ .or_else(|| {
6854
+ self.quiescent_action.take().and_then(|quiescent_action| match quiescent_action {
6855
+ QuiescentAction::Splice(instructions) => {
6856
+ let (inputs, outputs) = instructions.into_contributed_inputs_and_outputs();
6857
+ Some(SpliceFundingFailed {
6858
+ funding_txo: None,
6859
+ channel_type: None,
6860
+ contributed_inputs: inputs,
6861
+ contributed_outputs: outputs,
6862
+ })
6863
+ },
6864
+ #[cfg(any(test, fuzzing))]
6865
+ _ => {
6866
+ self.quiescent_action = Some(quiescent_action);
6867
+ None
6868
+ },
6869
+ })
6870
+ });
6871
+
6872
+ let mut shutdown_result = self.context.force_shutdown(&self.funding, closure_reason);
6873
+ shutdown_result.splice_funding_failed = splice_funding_failed;
6874
+ shutdown_result
6827
6875
}
6828
6876
6829
6877
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
@@ -10258,6 +10306,7 @@ where
10258
10306
is_manual_broadcast: self.context.is_manual_broadcast,
10259
10307
channel_funding_txo: self.funding.get_funding_txo(),
10260
10308
last_local_balance_msat: self.funding.value_to_self_msat,
10309
+ splice_funding_failed: None,
10261
10310
}
10262
10311
}
10263
10312
0 commit comments