From: Matt Corallo Date: Sun, 30 Sep 2018 23:11:01 +0000 (-0400) Subject: Use new ChannelError in funding_locked, filling out more handling X-Git-Tag: v0.0.12~297^2~3 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=662485a4ddb63058a967fd3fb81efc9faf924466;p=rust-lightning Use new ChannelError in funding_locked, filling out more handling --- diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 92f5ad0d5..762ecab5b 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -1387,9 +1387,9 @@ impl Channel { Ok(self.channel_monitor.clone()) } - pub fn funding_locked(&mut self, msg: &msgs::FundingLocked) -> Result<(), HandleError> { + pub fn funding_locked(&mut self, msg: &msgs::FundingLocked) -> Result<(), ChannelError> { if self.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 { - return Err(HandleError{err: "Peer sent funding_locked when we needed a channel_reestablish", action: Some(msgs::ErrorAction::SendErrorMessage{msg: msgs::ErrorMessage{data: "Peer sent funding_locked when we needed a channel_reestablish".to_string(), channel_id: msg.channel_id}})}); + return Err(ChannelError::Close("Peer sent funding_locked when we needed a channel_reestablish")); } let non_shutdown_state = self.channel_state & (!BOTH_SIDES_SHUTDOWN_MASK); if non_shutdown_state == ChannelState::FundingSent as u32 { @@ -1402,12 +1402,12 @@ impl Channel { self.cur_local_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 && self.cur_remote_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 { if self.their_cur_commitment_point != Some(msg.next_per_commitment_point) { - return Err(HandleError{err: "Peer sent a reconnect funding_locked with a different point", action: None}); + return Err(ChannelError::Close("Peer sent a reconnect funding_locked with a different point")); } // They probably disconnected/reconnected and re-sent the funding_locked, which is required return Ok(()); } else { - return Err(HandleError{err: "Peer sent a funding_locked at a strange time", action: None}); + return Err(ChannelError::Close("Peer sent a funding_locked at a strange time")); } self.their_prev_commitment_point = self.their_cur_commitment_point; diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index 08d597795..e3c717975 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -1616,7 +1616,8 @@ impl ChannelManager { //TODO: here and below MsgHandleErrInternal, #153 case return Err(MsgHandleErrInternal::send_err_msg_no_close("Got a message for a channel from the wrong node!", msg.channel_id)); } - chan.funding_locked(&msg).map_err(|e| MsgHandleErrInternal::from_maybe_close(e))?; + chan.funding_locked(&msg) + .map_err(|e| MsgHandleErrInternal::from_chan_maybe_close(e, msg.channel_id))?; return Ok(self.get_announcement_sigs(chan)); }, None => return Err(MsgHandleErrInternal::send_err_msg_no_close("Failed to find corresponding channel", msg.channel_id))