@@ -8835,10 +8835,7 @@ where
88358835
88368836 pub fn maybe_propose_closing_signed<F: Deref, L: Deref>(
88378837 &mut self, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
8838- ) -> Result<
8839- (Option<msgs::ClosingSigned>, Option<Transaction>, Option<ShutdownResult>),
8840- ChannelError,
8841- >
8838+ ) -> Result<(Option<msgs::ClosingSigned>, Option<(Transaction, ShutdownResult)>), ChannelError>
88428839 where
88438840 F::Target: FeeEstimator,
88448841 L::Target: Logger,
@@ -8848,20 +8845,20 @@ where
88488845 // initiate `closing_signed` negotiation until we're clear of all pending messages. Note
88498846 // that closing_negotiation_ready checks this case (as well as a few others).
88508847 if self.context.last_sent_closing_fee.is_some() || !self.closing_negotiation_ready() {
8851- return Ok((None, None, None ));
8848+ return Ok((None, None));
88528849 }
88538850
88548851 if !self.funding.is_outbound() {
88558852 if let Some(msg) = &self.context.pending_counterparty_closing_signed.take() {
88568853 return self.closing_signed(fee_estimator, &msg, logger);
88578854 }
8858- return Ok((None, None, None ));
8855+ return Ok((None, None));
88598856 }
88608857
88618858 // If we're waiting on a counterparty `commitment_signed` to clear some updates from our
88628859 // local commitment transaction, we can't yet initiate `closing_signed` negotiation.
88638860 if self.context.expecting_peer_commitment_signed {
8864- return Ok((None, None, None ));
8861+ return Ok((None, None));
88658862 }
88668863
88678864 let (our_min_fee, our_max_fee) = self.calculate_closing_fee_limits(fee_estimator);
@@ -8880,7 +8877,7 @@ where
88808877 our_max_fee,
88818878 logger,
88828879 );
8883- Ok((closing_signed, None, None ))
8880+ Ok((closing_signed, None))
88848881 }
88858882
88868883 fn mark_response_received(&mut self) {
@@ -9143,10 +9140,7 @@ where
91439140 pub fn closing_signed<F: Deref, L: Deref>(
91449141 &mut self, fee_estimator: &LowerBoundedFeeEstimator<F>, msg: &msgs::ClosingSigned,
91459142 logger: &L,
9146- ) -> Result<
9147- (Option<msgs::ClosingSigned>, Option<Transaction>, Option<ShutdownResult>),
9148- ChannelError,
9149- >
9143+ ) -> Result<(Option<msgs::ClosingSigned>, Option<(Transaction, ShutdownResult)>), ChannelError>
91509144 where
91519145 F::Target: FeeEstimator,
91529146 L::Target: Logger,
@@ -9186,7 +9180,7 @@ where
91869180
91879181 if self.context.channel_state.is_monitor_update_in_progress() {
91889182 self.context.pending_counterparty_closing_signed = Some(msg.clone());
9189- return Ok((None, None, None ));
9183+ return Ok((None, None));
91909184 }
91919185
91929186 let funding_redeemscript = self.funding.get_funding_redeemscript();
@@ -9240,7 +9234,7 @@ where
92409234 self.build_signed_closing_transaction(&mut closing_tx, &msg.signature, &sig);
92419235 self.context.channel_state = ChannelState::ShutdownComplete;
92429236 self.context.update_time_counter += 1;
9243- return Ok((None, Some(tx), Some( shutdown_result)));
9237+ return Ok((None, Some((tx, shutdown_result) )));
92449238 }
92459239 }
92469240
@@ -9263,26 +9257,25 @@ where
92639257 our_max_fee,
92649258 logger,
92659259 );
9266- let (signed_tx, shutdown_result) = if $new_fee == msg.fee_satoshis {
9267- let shutdown_result =
9268- closing_signed.as_ref().map(|_| self.shutdown_result_coop_close());
9269- if closing_signed.is_some() {
9270- self.context.channel_state = ChannelState::ShutdownComplete;
9271- }
9260+ let signed_tx_shutdown = if $new_fee == msg.fee_satoshis {
92729261 self.context.update_time_counter += 1;
92739262 self.context.last_received_closing_sig = Some(msg.signature.clone());
9274- let tx = closing_signed.as_ref().map(|ClosingSigned { signature, .. }| {
9275- self.build_signed_closing_transaction(
9263+ if let Some(ClosingSigned { signature, .. }) = &closing_signed {
9264+ let shutdown_result = self.shutdown_result_coop_close();
9265+ self.context.channel_state = ChannelState::ShutdownComplete;
9266+ let tx = self.build_signed_closing_transaction(
92769267 &closing_tx,
92779268 &msg.signature,
92789269 signature,
9279- )
9280- });
9281- (tx, shutdown_result)
9270+ );
9271+ Some((tx, shutdown_result))
9272+ } else {
9273+ None
9274+ }
92829275 } else {
9283- ( None, None)
9276+ None
92849277 };
9285- return Ok((closing_signed, signed_tx, shutdown_result ))
9278+ return Ok((closing_signed, signed_tx_shutdown ))
92869279 };
92879280 }
92889281
0 commit comments