@@ -6732,6 +6732,13 @@ impl FundingNegotiationContext {
67326732 let contributed_outputs = self.our_funding_outputs;
67336733 (contributed_inputs, contributed_outputs)
67346734 }
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+ }
67356742}
67366743
67376744// Holder designates channel data owned for the benefit of the user client.
@@ -6865,6 +6872,45 @@ pub struct SpliceFundingFailed {
68656872 pub contributed_outputs: Vec<bitcoin::TxOut>,
68666873}
68676874
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+
68686914pub struct SpliceFundingPromotion {
68696915 pub funding_txo: OutPoint,
68706916 pub monitor_update: Option<ChannelMonitorUpdate>,
@@ -6977,42 +7023,11 @@ where
69777023 debug_assert!(self.context.interactive_tx_signing_session.is_none());
69787024 self.context.channel_state.clear_quiescent();
69797025
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+ );
70167031
70177032 if self.pending_funding().is_empty() {
70187033 self.pending_splice.take();
@@ -7021,6 +7036,18 @@ where
70217036 splice_funding_failed
70227037 }
70237038
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+
70247051 #[rustfmt::skip]
70257052 fn check_remote_fee<F: Deref, L: Deref>(
70267053 channel_type: &ChannelTypeFeatures, fee_estimator: &LowerBoundedFeeEstimator<F>,
0 commit comments