@@ -6732,6 +6732,13 @@ impl FundingNegotiationContext {
6732
6732
let contributed_outputs = self.our_funding_outputs;
6733
6733
(contributed_inputs, contributed_outputs)
6734
6734
}
6735
+
6736
+ fn to_contributed_inputs_and_outputs(&self) -> (Vec<bitcoin::OutPoint>, Vec<TxOut>) {
6737
+ let contributed_inputs =
6738
+ self.our_funding_inputs.iter().map(|input| input.utxo.outpoint).collect();
6739
+ let contributed_outputs = self.our_funding_outputs.clone();
6740
+ (contributed_inputs, contributed_outputs)
6741
+ }
6735
6742
}
6736
6743
6737
6744
// Holder designates channel data owned for the benefit of the user client.
@@ -6865,6 +6872,45 @@ pub struct SpliceFundingFailed {
6865
6872
pub contributed_outputs: Vec<bitcoin::TxOut>,
6866
6873
}
6867
6874
6875
+ macro_rules! maybe_create_splice_funding_failed {
6876
+ ($pending_splice: expr, $get: ident, $contributed_inputs_and_outputs: ident) => {{
6877
+ $pending_splice
6878
+ .and_then(|pending_splice| pending_splice.funding_negotiation.$get())
6879
+ .filter(|funding_negotiation| funding_negotiation.is_initiator())
6880
+ .map(|funding_negotiation| {
6881
+ let funding_txo = funding_negotiation
6882
+ .as_funding()
6883
+ .and_then(|funding| funding.get_funding_txo())
6884
+ .map(|txo| txo.into_bitcoin_outpoint());
6885
+
6886
+ let channel_type = funding_negotiation
6887
+ .as_funding()
6888
+ .map(|funding| funding.get_channel_type().clone());
6889
+
6890
+ let (contributed_inputs, contributed_outputs) = match funding_negotiation {
6891
+ FundingNegotiation::AwaitingAck { context } => {
6892
+ context.$contributed_inputs_and_outputs()
6893
+ },
6894
+ FundingNegotiation::ConstructingTransaction {
6895
+ interactive_tx_constructor,
6896
+ ..
6897
+ } => interactive_tx_constructor.$contributed_inputs_and_outputs(),
6898
+ FundingNegotiation::AwaitingSignatures { .. } => {
6899
+ debug_assert!(false);
6900
+ (Vec::new(), Vec::new())
6901
+ },
6902
+ };
6903
+
6904
+ SpliceFundingFailed {
6905
+ funding_txo,
6906
+ channel_type,
6907
+ contributed_inputs,
6908
+ contributed_outputs,
6909
+ }
6910
+ })
6911
+ }};
6912
+ }
6913
+
6868
6914
pub struct SpliceFundingPromotion {
6869
6915
pub funding_txo: OutPoint,
6870
6916
pub monitor_update: Option<ChannelMonitorUpdate>,
@@ -6977,42 +7023,11 @@ where
6977
7023
debug_assert!(self.context.interactive_tx_signing_session.is_none());
6978
7024
self.context.channel_state.clear_quiescent();
6979
7025
6980
- let splice_funding_failed = self
6981
- . pending_splice
6982
- . as_mut ( )
6983
- . and_then ( |pending_splice| pending_splice. funding_negotiation . take ( ) )
6984
- . filter ( |funding_negotiation| funding_negotiation. is_initiator ( ) )
6985
- . map ( |funding_negotiation| {
6986
- let funding_txo = funding_negotiation
6987
- . as_funding ( )
6988
- . and_then ( |funding| funding. get_funding_txo ( ) )
6989
- . map ( |txo| txo. into_bitcoin_outpoint ( ) ) ;
6990
-
6991
- let channel_type = funding_negotiation
6992
- . as_funding ( )
6993
- . map ( |funding| funding. get_channel_type ( ) . clone ( ) ) ;
6994
-
6995
- let ( contributed_inputs, contributed_outputs) = match funding_negotiation {
6996
- FundingNegotiation :: AwaitingAck { context } => {
6997
- context. into_contributed_inputs_and_outputs ( )
6998
- } ,
6999
- FundingNegotiation :: ConstructingTransaction {
7000
- interactive_tx_constructor,
7001
- ..
7002
- } => interactive_tx_constructor. into_contributed_inputs_and_outputs ( ) ,
7003
- FundingNegotiation :: AwaitingSignatures { .. } => {
7004
- debug_assert ! ( false ) ;
7005
- ( Vec :: new ( ) , Vec :: new ( ) )
7006
- } ,
7007
- } ;
7008
-
7009
- SpliceFundingFailed {
7010
- funding_txo,
7011
- channel_type,
7012
- contributed_inputs,
7013
- contributed_outputs,
7014
- }
7015
- } ) ;
7026
+ let splice_funding_failed = maybe_create_splice_funding_failed!(
7027
+ self.pending_splice.as_mut(),
7028
+ take,
7029
+ into_contributed_inputs_and_outputs
7030
+ );
7016
7031
7017
7032
if self.pending_funding().is_empty() {
7018
7033
self.pending_splice.take();
@@ -7021,6 +7036,18 @@ where
7021
7036
splice_funding_failed
7022
7037
}
7023
7038
7039
+ pub(super) fn maybe_splice_funding_failed(&self) -> Option<SpliceFundingFailed> {
7040
+ if !self.should_reset_pending_splice_state() {
7041
+ return None;
7042
+ }
7043
+
7044
+ maybe_create_splice_funding_failed!(
7045
+ self.pending_splice.as_ref(),
7046
+ as_ref,
7047
+ to_contributed_inputs_and_outputs
7048
+ )
7049
+ }
7050
+
7024
7051
#[rustfmt::skip]
7025
7052
fn check_remote_fee<F: Deref, L: Deref>(
7026
7053
channel_type: &ChannelTypeFeatures, fee_estimator: &LowerBoundedFeeEstimator<F>,
0 commit comments