@@ -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.
@@ -2675,6 +2678,15 @@ pub(crate) struct SpliceInstructions {
2675
2678
locktime: u32,
2676
2679
}
2677
2680
2681
+ impl SpliceInstructions {
2682
+ fn into_contributed_inputs_and_outputs(self) -> (Vec<bitcoin::OutPoint>, Vec<TxOut>) {
2683
+ (
2684
+ self.our_funding_inputs.into_iter().map(|input| input.utxo.outpoint).collect(),
2685
+ self.our_funding_outputs,
2686
+ )
2687
+ }
2688
+ }
2689
+
2678
2690
impl_writeable_tlv_based!(SpliceInstructions, {
2679
2691
(1, adjusted_funding_contribution, required),
2680
2692
(3, our_funding_inputs, required_vec),
@@ -6029,6 +6041,7 @@ where
6029
6041
is_manual_broadcast: self.is_manual_broadcast,
6030
6042
channel_funding_txo: funding.get_funding_txo(),
6031
6043
last_local_balance_msat: funding.value_to_self_msat,
6044
+ splice_funding_failed: None,
6032
6045
}
6033
6046
}
6034
6047
@@ -6798,7 +6811,42 @@ where
6798
6811
}
6799
6812
6800
6813
pub fn force_shutdown(&mut self, closure_reason: ClosureReason) -> ShutdownResult {
6801
- self.context.force_shutdown(&self.funding, closure_reason)
6814
+ let splice_funding_failed = self
6815
+ .pending_splice
6816
+ .as_mut()
6817
+ .and_then(|pending_splice| pending_splice.funding_negotiation.take())
6818
+ .filter(|funding_negotiation| funding_negotiation.is_initiator())
6819
+ .map(|_funding_negotiation| {
6820
+ // FIXME: Populte after #4120 is merged
6821
+ SpliceFundingFailed {
6822
+ funding_txo: todo!(),
6823
+ channel_type: todo!(),
6824
+ contributed_inputs: todo!(),
6825
+ contributed_outputs: todo!(),
6826
+ }
6827
+ })
6828
+ .or_else(|| {
6829
+ self.quiescent_action.take().and_then(|quiescent_action| match quiescent_action {
6830
+ QuiescentAction::Splice(instructions) => {
6831
+ let (inputs, outputs) = instructions.into_contributed_inputs_and_outputs();
6832
+ Some(SpliceFundingFailed {
6833
+ funding_txo: None,
6834
+ channel_type: None,
6835
+ contributed_inputs: inputs,
6836
+ contributed_outputs: outputs,
6837
+ })
6838
+ },
6839
+ #[cfg(any(test, fuzzing))]
6840
+ _ => {
6841
+ self.quiescent_action = Some(quiescent_action);
6842
+ None
6843
+ },
6844
+ })
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
6802
6850
}
6803
6851
6804
6852
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
@@ -10233,6 +10281,7 @@ where
10233
10281
is_manual_broadcast: self.context.is_manual_broadcast,
10234
10282
channel_funding_txo: self.funding.get_funding_txo(),
10235
10283
last_local_balance_msat: self.funding.value_to_self_msat,
10284
+ splice_funding_failed: None,
10236
10285
}
10237
10286
}
10238
10287
0 commit comments