Skip to content

Commit 662485a

Browse files
committed
Use new ChannelError in funding_locked, filling out more handling
1 parent 625e2b3 commit 662485a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/ln/channel.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,9 +1387,9 @@ impl Channel {
13871387
Ok(self.channel_monitor.clone())
13881388
}
13891389

1390-
pub fn funding_locked(&mut self, msg: &msgs::FundingLocked) -> Result<(), HandleError> {
1390+
pub fn funding_locked(&mut self, msg: &msgs::FundingLocked) -> Result<(), ChannelError> {
13911391
if self.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 {
1392-
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}})});
1392+
return Err(ChannelError::Close("Peer sent funding_locked when we needed a channel_reestablish"));
13931393
}
13941394
let non_shutdown_state = self.channel_state & (!BOTH_SIDES_SHUTDOWN_MASK);
13951395
if non_shutdown_state == ChannelState::FundingSent as u32 {
@@ -1402,12 +1402,12 @@ impl Channel {
14021402
self.cur_local_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 &&
14031403
self.cur_remote_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
14041404
if self.their_cur_commitment_point != Some(msg.next_per_commitment_point) {
1405-
return Err(HandleError{err: "Peer sent a reconnect funding_locked with a different point", action: None});
1405+
return Err(ChannelError::Close("Peer sent a reconnect funding_locked with a different point"));
14061406
}
14071407
// They probably disconnected/reconnected and re-sent the funding_locked, which is required
14081408
return Ok(());
14091409
} else {
1410-
return Err(HandleError{err: "Peer sent a funding_locked at a strange time", action: None});
1410+
return Err(ChannelError::Close("Peer sent a funding_locked at a strange time"));
14111411
}
14121412

14131413
self.their_prev_commitment_point = self.their_cur_commitment_point;

src/ln/channelmanager.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,8 @@ impl ChannelManager {
16161616
//TODO: here and below MsgHandleErrInternal, #153 case
16171617
return Err(MsgHandleErrInternal::send_err_msg_no_close("Got a message for a channel from the wrong node!", msg.channel_id));
16181618
}
1619-
chan.funding_locked(&msg).map_err(|e| MsgHandleErrInternal::from_maybe_close(e))?;
1619+
chan.funding_locked(&msg)
1620+
.map_err(|e| MsgHandleErrInternal::from_chan_maybe_close(e, msg.channel_id))?;
16201621
return Ok(self.get_announcement_sigs(chan));
16211622
},
16221623
None => return Err(MsgHandleErrInternal::send_err_msg_no_close("Failed to find corresponding channel", msg.channel_id))

0 commit comments

Comments
 (0)