@@ -7886,11 +7886,12 @@ where
78867886 Ok(())
78877887 }
78887888
7889- #[rustfmt::skip]
78907889 pub fn initial_commitment_signed_v2<L: Deref>(
7891- &mut self, msg: &msgs::CommitmentSigned, best_block: BestBlock, signer_provider: &SP, logger: &L
7890+ &mut self, msg: &msgs::CommitmentSigned, best_block: BestBlock, signer_provider: &SP,
7891+ logger: &L,
78927892 ) -> Result<ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>, ChannelError>
7893- where L::Target: Logger
7893+ where
7894+ L::Target: Logger,
78947895 {
78957896 if let Some(signing_session) = self.context.interactive_tx_signing_session.as_ref() {
78967897 if signing_session.has_received_tx_signatures() {
@@ -7905,16 +7906,41 @@ where
79057906 };
79067907
79077908 let holder_commitment_point = &mut self.holder_commitment_point.clone();
7908- self.context.assert_no_commitment_advancement(holder_commitment_point.next_transaction_number(), "initial commitment_signed");
7909+ self.context.assert_no_commitment_advancement(
7910+ holder_commitment_point.next_transaction_number(),
7911+ "initial commitment_signed",
7912+ );
79097913
79107914 let (channel_monitor, _) = self.initial_commitment_signed(
7911- self.context.channel_id(), msg.signature, holder_commitment_point, best_block, signer_provider, logger)?;
7915+ self.context.channel_id(),
7916+ msg.signature,
7917+ holder_commitment_point,
7918+ best_block,
7919+ signer_provider,
7920+ logger,
7921+ )?;
79127922 self.holder_commitment_point = *holder_commitment_point;
79137923
7914- log_info!(logger, "Received initial commitment_signed from peer for channel {}", &self.context.channel_id());
7924+ log_info!(
7925+ logger,
7926+ "Received initial commitment_signed from peer for channel {}",
7927+ &self.context.channel_id()
7928+ );
79157929
7916- self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new(), logger);
7917- self.context.interactive_tx_signing_session.as_mut().expect("signing session should be present").received_commitment_signed();
7930+ self.monitor_updating_paused(
7931+ false,
7932+ false,
7933+ false,
7934+ Vec::new(),
7935+ Vec::new(),
7936+ Vec::new(),
7937+ logger,
7938+ );
7939+ self.context
7940+ .interactive_tx_signing_session
7941+ .as_mut()
7942+ .expect("signing session should be present")
7943+ .received_commitment_signed();
79187944 Ok(channel_monitor)
79197945 }
79207946
@@ -13769,34 +13795,61 @@ where
1376913795
1377013796 /// Handles a funding_signed message from the remote end.
1377113797 /// If this call is successful, broadcast the funding transaction (and not before!)
13772- #[rustfmt::skip]
1377313798 pub fn funding_signed<L: Deref>(
13774- mut self, msg: &msgs::FundingSigned, best_block: BestBlock, signer_provider: &SP, logger: &L
13775- ) -> Result<(FundedChannel<SP>, ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>), (OutboundV1Channel<SP>, ChannelError)>
13799+ mut self, msg: &msgs::FundingSigned, best_block: BestBlock, signer_provider: &SP,
13800+ logger: &L,
13801+ ) -> Result<
13802+ (FundedChannel<SP>, ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>),
13803+ (OutboundV1Channel<SP>, ChannelError),
13804+ >
1377613805 where
13777- L::Target: Logger
13806+ L::Target: Logger,
1377813807 {
1377913808 if !self.funding.is_outbound() {
13780- return Err((self, ChannelError::close("Received funding_signed for an inbound channel?".to_owned())));
13809+ return Err((
13810+ self,
13811+ ChannelError::close("Received funding_signed for an inbound channel?".to_owned()),
13812+ ));
1378113813 }
1378213814 if !matches!(self.context.channel_state, ChannelState::FundingNegotiated(_)) {
13783- return Err((self, ChannelError::close("Received funding_signed in strange state!".to_owned())));
13815+ return Err((
13816+ self,
13817+ ChannelError::close("Received funding_signed in strange state!".to_owned()),
13818+ ));
1378413819 }
13785- let mut holder_commitment_point = match self.unfunded_context.holder_commitment_point {
13786- Some(point) => point,
13787- None => return Err((self, ChannelError::close("Received funding_signed before our first commitment point was available".to_owned()))),
13788- };
13789- self.context.assert_no_commitment_advancement(holder_commitment_point.next_transaction_number(), "funding_signed");
13820+ let mut holder_commitment_point =
13821+ match self.unfunded_context.holder_commitment_point {
13822+ Some(point) => point,
13823+ None => return Err((
13824+ self,
13825+ ChannelError::close(
13826+ "Received funding_signed before our first commitment point was available"
13827+ .to_owned(),
13828+ ),
13829+ )),
13830+ };
13831+ self.context.assert_no_commitment_advancement(
13832+ holder_commitment_point.next_transaction_number(),
13833+ "funding_signed",
13834+ );
1379013835
1379113836 let (channel_monitor, _) = match self.initial_commitment_signed(
13792- self.context.channel_id(), msg.signature,
13793- &mut holder_commitment_point, best_block, signer_provider, logger
13837+ self.context.channel_id(),
13838+ msg.signature,
13839+ &mut holder_commitment_point,
13840+ best_block,
13841+ signer_provider,
13842+ logger,
1379413843 ) {
1379513844 Ok(channel_monitor) => channel_monitor,
1379613845 Err(err) => return Err((self, err)),
1379713846 };
1379813847
13799- log_info!(logger, "Received funding_signed from peer for channel {}", &self.context.channel_id());
13848+ log_info!(
13849+ logger,
13850+ "Received funding_signed from peer for channel {}",
13851+ &self.context.channel_id()
13852+ );
1380013853
1380113854 let mut channel = FundedChannel {
1380213855 funding: self.funding,
@@ -13808,7 +13861,15 @@ where
1380813861
1380913862 let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
1381013863 || channel.context.signer_pending_channel_ready;
13811- channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new(), logger);
13864+ channel.monitor_updating_paused(
13865+ false,
13866+ false,
13867+ need_channel_ready,
13868+ Vec::new(),
13869+ Vec::new(),
13870+ Vec::new(),
13871+ logger,
13872+ );
1381213873 Ok((channel, channel_monitor))
1381313874 }
1381413875
@@ -14041,15 +14102,25 @@ where
1404114102 self.generate_accept_channel_message(logger)
1404214103 }
1404314104
14044- #[rustfmt::skip]
1404514105 pub fn funding_created<L: Deref>(
14046- mut self, msg: &msgs::FundingCreated, best_block: BestBlock, signer_provider: &SP, logger: &L
14047- ) -> Result<(FundedChannel<SP>, Option<msgs::FundingSigned>, ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>), (Self, ChannelError)>
14106+ mut self, msg: &msgs::FundingCreated, best_block: BestBlock, signer_provider: &SP,
14107+ logger: &L,
14108+ ) -> Result<
14109+ (
14110+ FundedChannel<SP>,
14111+ Option<msgs::FundingSigned>,
14112+ ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>,
14113+ ),
14114+ (Self, ChannelError),
14115+ >
1404814116 where
14049- L::Target: Logger
14117+ L::Target: Logger,
1405014118 {
1405114119 if self.funding.is_outbound() {
14052- return Err((self, ChannelError::close("Received funding_created for an outbound channel?".to_owned())));
14120+ return Err((
14121+ self,
14122+ ChannelError::close("Received funding_created for an outbound channel?".to_owned()),
14123+ ));
1405314124 }
1405414125 if !matches!(
1405514126 self.context.channel_state, ChannelState::NegotiatingFunding(flags)
@@ -14058,31 +14129,57 @@ where
1405814129 // BOLT 2 says that if we disconnect before we send funding_signed we SHOULD NOT
1405914130 // remember the channel, so it's safe to just send an error_message here and drop the
1406014131 // channel.
14061- return Err((self, ChannelError::close("Received funding_created after we got the channel!".to_owned())));
14132+ return Err((
14133+ self,
14134+ ChannelError::close(
14135+ "Received funding_created after we got the channel!".to_owned(),
14136+ ),
14137+ ));
1406214138 }
14063- let mut holder_commitment_point = match self.unfunded_context.holder_commitment_point {
14064- Some(point) => point,
14065- None => return Err((self, ChannelError::close("Received funding_created before our first commitment point was available".to_owned()))),
14066- };
14067- self.context.assert_no_commitment_advancement(holder_commitment_point.next_transaction_number(), "funding_created");
14139+ let mut holder_commitment_point =
14140+ match self.unfunded_context.holder_commitment_point {
14141+ Some(point) => point,
14142+ None => return Err((
14143+ self,
14144+ ChannelError::close(
14145+ "Received funding_created before our first commitment point was available"
14146+ .to_owned(),
14147+ ),
14148+ )),
14149+ };
14150+ self.context.assert_no_commitment_advancement(
14151+ holder_commitment_point.next_transaction_number(),
14152+ "funding_created",
14153+ );
1406814154
1406914155 let funding_txo = OutPoint { txid: msg.funding_txid, index: msg.funding_output_index };
1407014156 self.funding.channel_transaction_parameters.funding_outpoint = Some(funding_txo);
1407114157
14072- let (channel_monitor, counterparty_initial_commitment_tx) = match self.initial_commitment_signed(
14073- ChannelId::v1_from_funding_outpoint(funding_txo), msg.signature,
14074- &mut holder_commitment_point, best_block, signer_provider, logger
14075- ) {
14158+ let (channel_monitor, counterparty_initial_commitment_tx) = match self
14159+ .initial_commitment_signed(
14160+ ChannelId::v1_from_funding_outpoint(funding_txo),
14161+ msg.signature,
14162+ &mut holder_commitment_point,
14163+ best_block,
14164+ signer_provider,
14165+ logger,
14166+ ) {
1407614167 Ok(channel_monitor) => channel_monitor,
1407714168 Err(err) => return Err((self, err)),
1407814169 };
1407914170
1408014171 let funding_signed = self.context.get_funding_signed_msg(
14081- &self.funding.channel_transaction_parameters, logger, counterparty_initial_commitment_tx
14172+ &self.funding.channel_transaction_parameters,
14173+ logger,
14174+ counterparty_initial_commitment_tx,
1408214175 );
1408314176
14084- log_info!(logger, "{} funding_signed for peer for channel {}",
14085- if funding_signed.is_some() { "Generated" } else { "Waiting for signature on" }, &self.context.channel_id());
14177+ log_info!(
14178+ logger,
14179+ "{} funding_signed for peer for channel {}",
14180+ if funding_signed.is_some() { "Generated" } else { "Waiting for signature on" },
14181+ &self.context.channel_id()
14182+ );
1408614183
1408714184 // Promote the channel to a full-fledged one now that we have updated the state and have a
1408814185 // `ChannelMonitor`.
@@ -14095,7 +14192,15 @@ where
1409514192 };
1409614193 let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
1409714194 || channel.context.signer_pending_channel_ready;
14098- channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new(), logger);
14195+ channel.monitor_updating_paused(
14196+ false,
14197+ false,
14198+ need_channel_ready,
14199+ Vec::new(),
14200+ Vec::new(),
14201+ Vec::new(),
14202+ logger,
14203+ );
1409914204
1410014205 Ok((channel, funding_signed, channel_monitor))
1410114206 }
0 commit comments