Skip to content

Commit 414e543

Browse files
committed
Add DecodeError::DangerousValue for decoding invalid channel managers
This would help distinguish different types of errors when deserialzing a channel manager. InvalidValue was used previously but this could be because it is an old serialization format, whereas DangerousValue is a lot more clear on why the deserialization failed.
1 parent 5e41425 commit 414e543

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lightning/src/ln/channelmanager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10927,13 +10927,13 @@ where
1092710927
log_error!(logger, " client applications must ensure that ChannelMonitor data is always available and the latest to avoid funds loss!");
1092810928
log_error!(logger, " Without the latest ChannelMonitor we cannot continue without risking funds.");
1092910929
log_error!(logger, " Please ensure the chain::Watch API requirements are met and file a bug report at https://github.com/lightningdevkit/rust-lightning");
10930-
return Err(DecodeError::InvalidValue);
10930+
return Err(DecodeError::DangerousValue);
1093110931
}
1093210932
} else {
1093310933
// We shouldn't have persisted (or read) any unfunded channel types so none should have been
1093410934
// created in this `channel_by_id` map.
1093510935
debug_assert!(false);
10936-
return Err(DecodeError::InvalidValue);
10936+
return Err(DecodeError::DangerousValue);
1093710937
}
1093810938
}
1093910939
}

lightning/src/ln/msgs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ pub enum DecodeError {
9191
Io(io::ErrorKind),
9292
/// The message included zlib-compressed values, which we don't support.
9393
UnsupportedCompression,
94+
/// Value is validly encoded but is dangerous to use.
95+
/// This is used for things like [`crate::ln::channelmanager::ChannelManager`] deserialization
96+
/// where we want to ensure that we don't use a [`crate::ln::channelmanager::ChannelManager`]
97+
/// which is in the past.
98+
DangerousValue,
9499
}
95100

96101
/// An [`init`] message to be sent to or received from a peer.

0 commit comments

Comments
 (0)