]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Use new ChannelError in funding_locked, filling out more handling
authorMatt Corallo <git@bluematt.me>
Sun, 30 Sep 2018 23:11:01 +0000 (19:11 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 1 Oct 2018 00:05:39 +0000 (20:05 -0400)
src/ln/channel.rs
src/ln/channelmanager.rs

index 92f5ad0d50ef18ecd2c0be0f26a1bf1ae0fab75b..762ecab5b20614e11b67e4aa3b318f81d7840916 100644 (file)
@@ -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;
index 08d597795f32990b172a0aafd2a8169a1b158cd1..e3c717975e4c0b3a8236a55920f3da692babb2fc 100644 (file)
@@ -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))