@@ -1176,6 +1176,18 @@ pub enum UpdateFulfillCommitFetch {
11761176 DuplicateClaim {},
11771177}
11781178
1179+ /// Error returned when processing an invalid interactive-tx message from our counterparty.
1180+ pub(super) struct InteractiveTxMsgError {
1181+ /// The underlying error.
1182+ pub(super) err: ChannelError,
1183+ /// If a splice was in progress when processing the message, this contains the splice funding
1184+ /// information for emitting a `SpliceFailed` event.
1185+ pub(super) splice_funding_failed: Option<SpliceFundingFailed>,
1186+ /// Whether we were quiescent when we received the message, and are no longer due to aborting
1187+ /// the session.
1188+ pub(super) exited_quiescence: bool,
1189+ }
1190+
11791191/// The return value of `monitor_updating_restored`
11801192pub(super) struct MonitorRestoreUpdates {
11811193 pub raa: Option<msgs::RevokeAndACK>,
@@ -1818,104 +1830,118 @@ where
18181830
18191831 fn fail_interactive_tx_negotiation<L: Logger>(
18201832 &mut self, reason: AbortReason, logger: &L,
1821- ) -> (ChannelError, Option<SpliceFundingFailed>) {
1833+ ) -> InteractiveTxMsgError {
18221834 let logger = WithChannelContext::from(logger, &self.context(), None);
18231835 log_info!(logger, "Failed interactive transaction negotiation: {reason}");
18241836
1825- let splice_funding_failed = match &mut self.phase {
1837+ let ( splice_funding_failed, exited_quiescence) = match &mut self.phase {
18261838 ChannelPhase::Undefined => unreachable!(),
1827- ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => None,
1839+ ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
1840+ (None, false)
1841+ },
18281842 ChannelPhase::UnfundedV2(pending_v2_channel) => {
18291843 pending_v2_channel.interactive_tx_constructor.take();
1830- None
1844+ ( None, false)
18311845 },
18321846 ChannelPhase::Funded(funded_channel) => {
18331847 if funded_channel.should_reset_pending_splice_state(false) {
1834- funded_channel.reset_pending_splice_state()
1848+ ( funded_channel.reset_pending_splice_state(), true )
18351849 } else {
18361850 debug_assert!(false, "We should never fail an interactive funding negotiation once we're exchanging tx_signatures");
1837- None
1851+ ( None, false)
18381852 }
18391853 },
18401854 };
18411855
1842- (ChannelError::Abort(reason), splice_funding_failed)
1856+ InteractiveTxMsgError {
1857+ err: ChannelError::Abort(reason),
1858+ splice_funding_failed,
1859+ exited_quiescence,
1860+ }
18431861 }
18441862
18451863 pub fn tx_add_input<L: Logger>(
18461864 &mut self, msg: &msgs::TxAddInput, logger: &L,
1847- ) -> Result<InteractiveTxMessageSend, (ChannelError, Option<SpliceFundingFailed>) > {
1865+ ) -> Result<InteractiveTxMessageSend, InteractiveTxMsgError > {
18481866 match self.interactive_tx_constructor_mut() {
18491867 Some(interactive_tx_constructor) => interactive_tx_constructor
18501868 .handle_tx_add_input(msg)
18511869 .map_err(|reason| self.fail_interactive_tx_negotiation(reason, logger)),
1852- None => Err((
1853- ChannelError::WarnAndDisconnect(
1870+ None => Err(InteractiveTxMsgError {
1871+ err: ChannelError::WarnAndDisconnect(
18541872 "Received unexpected interactive transaction negotiation message".to_owned(),
18551873 ),
1856- None,
1857- )),
1874+ splice_funding_failed: None,
1875+ exited_quiescence: false,
1876+ }),
18581877 }
18591878 }
18601879
18611880 pub fn tx_add_output<L: Logger>(
18621881 &mut self, msg: &msgs::TxAddOutput, logger: &L,
1863- ) -> Result<InteractiveTxMessageSend, (ChannelError, Option<SpliceFundingFailed>) > {
1882+ ) -> Result<InteractiveTxMessageSend, InteractiveTxMsgError > {
18641883 match self.interactive_tx_constructor_mut() {
18651884 Some(interactive_tx_constructor) => interactive_tx_constructor
18661885 .handle_tx_add_output(msg)
18671886 .map_err(|reason| self.fail_interactive_tx_negotiation(reason, logger)),
1868- None => Err((
1869- ChannelError::WarnAndDisconnect(
1887+ None => Err(InteractiveTxMsgError {
1888+ err: ChannelError::WarnAndDisconnect(
18701889 "Received unexpected interactive transaction negotiation message".to_owned(),
18711890 ),
1872- None,
1873- )),
1891+ splice_funding_failed: None,
1892+ exited_quiescence: false,
1893+ }),
18741894 }
18751895 }
18761896
18771897 pub fn tx_remove_input<L: Logger>(
18781898 &mut self, msg: &msgs::TxRemoveInput, logger: &L,
1879- ) -> Result<InteractiveTxMessageSend, (ChannelError, Option<SpliceFundingFailed>) > {
1899+ ) -> Result<InteractiveTxMessageSend, InteractiveTxMsgError > {
18801900 match self.interactive_tx_constructor_mut() {
18811901 Some(interactive_tx_constructor) => interactive_tx_constructor
18821902 .handle_tx_remove_input(msg)
18831903 .map_err(|reason| self.fail_interactive_tx_negotiation(reason, logger)),
1884- None => Err((
1885- ChannelError::WarnAndDisconnect(
1904+ None => Err(InteractiveTxMsgError {
1905+ err: ChannelError::WarnAndDisconnect(
18861906 "Received unexpected interactive transaction negotiation message".to_owned(),
18871907 ),
1888- None,
1889- )),
1908+ splice_funding_failed: None,
1909+ exited_quiescence: false,
1910+ }),
18901911 }
18911912 }
18921913
18931914 pub fn tx_remove_output<L: Logger>(
18941915 &mut self, msg: &msgs::TxRemoveOutput, logger: &L,
1895- ) -> Result<InteractiveTxMessageSend, (ChannelError, Option<SpliceFundingFailed>) > {
1916+ ) -> Result<InteractiveTxMessageSend, InteractiveTxMsgError > {
18961917 match self.interactive_tx_constructor_mut() {
18971918 Some(interactive_tx_constructor) => interactive_tx_constructor
18981919 .handle_tx_remove_output(msg)
18991920 .map_err(|reason| self.fail_interactive_tx_negotiation(reason, logger)),
1900- None => Err((
1901- ChannelError::WarnAndDisconnect(
1921+ None => Err(InteractiveTxMsgError {
1922+ err: ChannelError::WarnAndDisconnect(
19021923 "Received unexpected interactive transaction negotiation message".to_owned(),
19031924 ),
1904- None,
1905- )),
1925+ splice_funding_failed: None,
1926+ exited_quiescence: false,
1927+ }),
19061928 }
19071929 }
19081930
19091931 pub fn tx_complete<F: FeeEstimator, L: Logger>(
19101932 &mut self, msg: &msgs::TxComplete, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1911- ) -> Result<TxCompleteResult, (ChannelError, Option<SpliceFundingFailed>) > {
1933+ ) -> Result<TxCompleteResult, InteractiveTxMsgError > {
19121934 let tx_complete_action = match self.interactive_tx_constructor_mut() {
19131935 Some(interactive_tx_constructor) => interactive_tx_constructor
19141936 .handle_tx_complete(msg)
19151937 .map_err(|reason| self.fail_interactive_tx_negotiation(reason, logger))?,
19161938 None => {
19171939 let err = "Received unexpected interactive transaction negotiation message";
1918- return Err((ChannelError::WarnAndDisconnect(err.to_owned()), None));
1940+ return Err(InteractiveTxMsgError {
1941+ err: ChannelError::WarnAndDisconnect(err.to_owned()),
1942+ splice_funding_failed: None,
1943+ exited_quiescence: false,
1944+ });
19191945 },
19201946 };
19211947
0 commit comments