Ok(msg) => msg,
Err(e) => match e {
msgs::DecodeError::UnknownRealmByte => return,
+ msgs::DecodeError::UnknownRequiredFeature => return,
msgs::DecodeError::BadPublicKey => return,
msgs::DecodeError::BadSignature => return,
msgs::DecodeError::BadText => return,
Ok(msg) => msg,
Err(e) => match e {
msgs::DecodeError::UnknownRealmByte => return,
+ msgs::DecodeError::UnknownRequiredFeature => return,
msgs::DecodeError::BadPublicKey => return,
msgs::DecodeError::BadSignature => return,
msgs::DecodeError::BadText => return,
Ok(msg) => msg,
Err(e) => match e {
msgs::DecodeError::UnknownRealmByte => return,
+ msgs::DecodeError::UnknownRequiredFeature => return,
msgs::DecodeError::BadPublicKey => return,
msgs::DecodeError::BadSignature => return,
msgs::DecodeError::BadText => return,
pub enum DecodeError {
/// Unknown realm byte in an OnionHopData packet
UnknownRealmByte,
+ /// Unknown feature mandating we fail to parse message
+ UnknownRequiredFeature,
/// Failed to decode a public key (ie it's invalid)
BadPublicKey,
/// Failed to decode a signature (ie it's invalid)
fn description(&self) -> &str {
match *self {
DecodeError::UnknownRealmByte => "Unknown realm byte in Onion packet",
+ DecodeError::UnknownRequiredFeature => "Unknown required feature preventing decode",
DecodeError::BadPublicKey => "Invalid public key in packet",
DecodeError::BadSignature => "Invalid signature in packet",
DecodeError::BadText => "Invalid text in packet",
impl MsgDecodable for UnsignedNodeAnnouncement {
fn decode(v: &[u8]) -> Result<Self, DecodeError> {
let features = GlobalFeatures::decode(&v[..])?;
+ if features.requires_unknown_bits() {
+ return Err(DecodeError::UnknownRequiredFeature);
+ }
+
if v.len() < features.encoded_len() + 4 + 33 + 3 + 32 + 2 {
return Err(DecodeError::ShortRead);
}
impl MsgDecodable for UnsignedChannelAnnouncement {
fn decode(v: &[u8]) -> Result<Self, DecodeError> {
let features = GlobalFeatures::decode(&v[..])?;
+ if features.requires_unknown_bits() {
+ return Err(DecodeError::UnknownRequiredFeature);
+ }
if v.len() < features.encoded_len() + 32 + 8 + 33*4 {
return Err(DecodeError::ShortRead);
}
Err(e) => {
match e {
msgs::DecodeError::UnknownRealmByte => return Err(PeerHandleError{ no_connection_possible: false }),
+ msgs::DecodeError::UnknownRequiredFeature => {
+ log_debug!(self, "Got a channel/node announcement with an known required feature flag, you may want to udpate!");
+ continue;
+ },
msgs::DecodeError::BadPublicKey => return Err(PeerHandleError{ no_connection_possible: false }),
msgs::DecodeError::BadSignature => return Err(PeerHandleError{ no_connection_possible: false }),
msgs::DecodeError::BadText => return Err(PeerHandleError{ no_connection_possible: false }),
let msg_hash = Message::from_slice(&Sha256dHash::from_data(&msg.contents.encode()[..])[..]).unwrap();
secp_verify_sig!(self.secp_ctx, &msg_hash, &msg.signature, &msg.contents.node_id);
+ if msg.contents.features.requires_unknown_bits() {
+ panic!("Unknown-required-features NodeAnnouncements should never deserialize!");
+ }
+
let mut network = self.network_map.write().unwrap();
match network.nodes.get_mut(&msg.contents.node_id) {
None => Err(HandleError{err: "No existing channels for node_announcement", action: Some(ErrorAction::IgnoreError)}),
//TODO: Only allow bitcoin chain_hash
if msg.contents.features.requires_unknown_bits() {
- return Err(HandleError{err: "Channel announcement required unknown feature flags", action: None});
+ panic!("Unknown-required-features ChannelAnnouncements should never deserialize!");
}
let mut network = self.network_map.write().unwrap();