Skip to content

Commit cfeb0c9

Browse files
committed
Add ChannelError::SendError variant
When moving ChannelPhase logic from ChannelManager into Channel, it is useful to error when a Channel is not in the expected state. Add a ChannelError::SendError variant for this purpose, which results in sending an error message without closing the channel.
1 parent f8975d9 commit cfeb0c9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lightning/src/ln/channel.rs

+3
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ pub(super) enum ChannelError {
713713
Ignore(String),
714714
Warn(String),
715715
Close((String, ClosureReason)),
716+
SendError(String),
716717
}
717718

718719
impl fmt::Debug for ChannelError {
@@ -721,6 +722,7 @@ impl fmt::Debug for ChannelError {
721722
&ChannelError::Ignore(ref e) => write!(f, "Ignore : {}", e),
722723
&ChannelError::Warn(ref e) => write!(f, "Warn : {}", e),
723724
&ChannelError::Close((ref e, _)) => write!(f, "Close : {}", e),
725+
&ChannelError::SendError(ref e) => write!(f, "Not Found : {}", e),
724726
}
725727
}
726728
}
@@ -731,6 +733,7 @@ impl fmt::Display for ChannelError {
731733
&ChannelError::Ignore(ref e) => write!(f, "{}", e),
732734
&ChannelError::Warn(ref e) => write!(f, "{}", e),
733735
&ChannelError::Close((ref e, _)) => write!(f, "{}", e),
736+
&ChannelError::SendError(ref e) => write!(f, "{}", e),
734737
}
735738
}
736739
}

lightning/src/ln/channelmanager.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ impl MsgHandleErrInternal {
800800
err: msg,
801801
action: msgs::ErrorAction::IgnoreError,
802802
},
803-
ChannelError::Close((msg, _reason)) => LightningError {
803+
ChannelError::Close((msg, _)) | ChannelError::SendError(msg) => LightningError {
804804
err: msg.clone(),
805805
action: msgs::ErrorAction::SendErrorMessage {
806806
msg: msgs::ErrorMessage {
@@ -3030,6 +3030,9 @@ macro_rules! convert_channel_err {
30303030
MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, shutdown_res, $channel_update);
30313031
(true, err)
30323032
},
3033+
ChannelError::SendError(msg) => {
3034+
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::SendError(msg), *$channel_id))
3035+
},
30333036
}
30343037
};
30353038
($self: ident, $peer_state: expr, $err: expr, $funded_channel: expr, $channel_id: expr, FUNDED_CHANNEL) => {

0 commit comments

Comments
 (0)