@@ -1754,56 +1754,34 @@ where
1754
1754
let logger = WithChannelContext::from(logger, &self.context(), None);
1755
1755
log_info!(logger, "Failed interactive transaction negotiation: {reason}");
1756
1756
1757
- let mut splice_failed = None;
1758
-
1759
- let _interactive_tx_constructor = match &mut self.phase {
1757
+ let splice_funding_failed = match &mut self.phase {
1760
1758
ChannelPhase::Undefined => unreachable!(),
1761
1759
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => None,
1762
1760
ChannelPhase::UnfundedV2(pending_v2_channel) => {
1763
- pending_v2_channel.interactive_tx_constructor.take()
1761
+ pending_v2_channel.interactive_tx_constructor.take();
1762
+ None
1764
1763
},
1765
1764
ChannelPhase::Funded(funded_channel) => {
1766
- if let Some(pending_splice) = funded_channel.pending_splice.as_mut() {
1767
- if pending_splice.funding_negotiation.is_some() {
1768
- let funding_negotiation = pending_splice.funding_negotiation.take();
1769
-
1770
- let (funding_txo, channel_type, contributed_inputs, contributed_outputs) =
1771
- if let Some(FundingNegotiation::ConstructingTransaction { funding, interactive_tx_constructor: _ }) = &funding_negotiation {
1772
- (
1773
- funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()),
1774
- Some(funding.get_channel_type().clone()),
1775
- Vec::new(), // TODO: Extract contributed inputs from interactive_tx_constructor
1776
- Vec::new(), // TODO: Extract contributed outputs from interactive_tx_constructor
1777
- )
1778
- } else {
1779
- (None, None, Vec::new(), Vec::new())
1780
- };
1781
-
1782
- splice_failed = Some(SpliceFundingFailed {
1765
+ funded_channel
1766
+ .pending_splice
1767
+ .as_mut()
1768
+ .and_then(|pending_splice| pending_splice.funding_negotiation.take())
1769
+ .map(|funding_negotiation| {
1770
+ let funding = funding_negotiation.as_funding();
1771
+ SpliceFundingFailed {
1783
1772
channel_id: funded_channel.context.channel_id,
1784
1773
counterparty_node_id: funded_channel.context.counterparty_node_id,
1785
1774
user_channel_id: funded_channel.context.user_id,
1786
- funding_txo,
1787
- channel_type,
1788
- contributed_inputs,
1789
- contributed_outputs,
1790
- });
1791
-
1792
- if let Some(FundingNegotiation::ConstructingTransaction { interactive_tx_constructor, .. }) = funding_negotiation {
1793
- Some(interactive_tx_constructor)
1794
- } else {
1795
- None
1775
+ funding_txo: funding.as_ref().and_then(|funding| funding.get_funding_txo()).map(|txo| txo.into_bitcoin_outpoint()),
1776
+ channel_type: funding.as_ref().map(|funding| funding.get_channel_type().clone()),
1777
+ contributed_inputs: Vec::new(),
1778
+ contributed_outputs: Vec::new(),
1796
1779
}
1797
- } else {
1798
- None
1799
- }
1800
- } else {
1801
- None
1802
- }
1780
+ })
1803
1781
},
1804
1782
};
1805
1783
1806
- (reason.into_tx_abort_msg(self.context().channel_id), splice_failed )
1784
+ (reason.into_tx_abort_msg(self.context().channel_id), splice_funding_failed )
1807
1785
}
1808
1786
1809
1787
pub fn tx_add_input<L: Deref>(
@@ -2024,18 +2002,20 @@ where
2024
2002
} = funding_negotiation
2025
2003
{
2026
2004
let signing_session = interactive_tx_constructor.into_signing_session();
2027
- let commitment_signed = chan.context.funding_tx_constructed(
2005
+ let commitment_signed_result = chan.context.funding_tx_constructed(
2028
2006
&mut funding,
2029
2007
signing_session,
2030
2008
true,
2031
2009
chan.holder_commitment_point.next_transaction_number(),
2032
2010
&&logger,
2033
- )? ;
2011
+ );
2034
2012
2013
+ // This must be set even if returning an Err. Otherwise,
2014
+ // fail_interactive_tx_negotiation won't produce a SpliceFailed event.
2035
2015
pending_splice.funding_negotiation =
2036
2016
Some(FundingNegotiation::AwaitingSignatures { funding });
2037
2017
2038
- return Ok(commitment_signed) ;
2018
+ return commitment_signed_result ;
2039
2019
} else {
2040
2020
// Replace the taken state
2041
2021
pending_splice.funding_negotiation = Some(funding_negotiation);
0 commit comments