Skip to content

Raise APIError from close_channel #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2018

Conversation

yuntai
Copy link
Contributor

@yuntai yuntai commented Sep 25, 2018

No description provided.

}
assert_eq!(self.channel_state & ChannelState::ShutdownComplete as u32, 0);
if self.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 {
return Err(HandleError{err: "Cannot begin shutdown while peer is disconnected, maybe force-close instead?", action: None});
return Err(APIError::APIMisuseError{err: "Cannot begin shutdown while peer is disconnected, maybe force-close instead?"});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, can we really call this "Misuse"? Maybe some less-user-blaming enum entry in APIError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added ChannelUnavailalbe enum entry for APIError.

for htlc in self.pending_outbound_htlcs.iter() {
if htlc.state == OutboundHTLCState::LocalAnnounced {
return Err(HandleError{err: "Cannot begin shutdown with pending HTLCs, call send_commitment first", action: None});
return Err(APIError::APIMisuseError{err: "Cannot begin shutdown with pending HTLCs. Process pending events first"});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can debug_assert!(false) here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the client can call close_channel() anytime?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, oops, confused myself as to what LocalAnnounced meant. Forgot that it implied "included in sent commitment_signed". Indeed, I was mistaken.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -439,7 +439,7 @@ impl ChannelManager {
(res, chan_entry.get().get_their_node_id(), Some(chan_entry.remove_entry().1))
} else { (res, chan_entry.get().get_their_node_id(), None) }
},
hash_map::Entry::Vacant(_) => return Err(HandleError{err: "No such channel", action: None})
hash_map::Entry::Vacant(_) => return Err(APIError::APIMisuseError{err: "No such channel"})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt this also be ChannelUnavailable (after all, there are always going to be races on the client's side where a channel gets (force-)closed between when they decide to close it and when they call close_channel).

@yuntai yuntai changed the title raise APIError from close_channel Raise APIError from close_channel Oct 3, 2018
@TheBlueMatt TheBlueMatt merged commit a82a5f7 into lightningdevkit:master Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants