X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fmsgs.rs;h=a27b896701412918886d3c890074f03fdfe5f64a;hb=refs%2Fheads%2F2019-07-no-unsafe;hp=6aa9e05b242fd7a53018c70cb05dd170d5d49432;hpb=35853a607d53b8987ebe4d4c7b7119fc188e1e32;p=rust-lightning diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index 6aa9e05b..a27b8967 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -59,9 +59,17 @@ pub struct LocalFeatures { } impl LocalFeatures { + /// Create a blank LocalFeatures flags (visibility extended for fuzz tests) + #[cfg(not(feature = "fuzztarget"))] pub(crate) fn new() -> LocalFeatures { LocalFeatures { - flags: Vec::new(), + flags: vec![1 << 4], + } + } + #[cfg(feature = "fuzztarget")] + pub fn new() -> LocalFeatures { + LocalFeatures { + flags: vec![1 << 4], } } @@ -86,8 +94,8 @@ impl LocalFeatures { pub(crate) fn supports_upfront_shutdown_script(&self) -> bool { self.flags.len() > 0 && (self.flags[0] & (3 << 4)) != 0 } - pub(crate) fn requires_upfront_shutdown_script(&self) -> bool { - self.flags.len() > 0 && (self.flags[0] & (1 << 4)) != 0 + pub(crate) fn unset_upfront_shutdown_script(&mut self) { + self.flags[0] ^= 1 << 4; } pub(crate) fn requires_unknown_bits(&self) -> bool { @@ -611,9 +619,9 @@ pub enum OptionalField { pub trait ChannelMessageHandler : events::MessageSendEventsProvider + Send + Sync { //Channel init: /// Handle an incoming open_channel message from the given peer. - fn handle_open_channel(&self, their_node_id: &PublicKey, msg: &OpenChannel) -> Result<(), HandleError>; + fn handle_open_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &OpenChannel) -> Result<(), HandleError>; /// Handle an incoming accept_channel message from the given peer. - fn handle_accept_channel(&self, their_node_id: &PublicKey, msg: &AcceptChannel) -> Result<(), HandleError>; + fn handle_accept_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &AcceptChannel) -> Result<(), HandleError>; /// Handle an incoming funding_created message from the given peer. fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &FundingCreated) -> Result<(), HandleError>; /// Handle an incoming funding_signed message from the given peer. @@ -705,7 +713,6 @@ mod fuzzy_internal_msgs { pub(crate) data: OnionRealm0HopData, pub(crate) hmac: [u8; 32], } - unsafe impl ::util::internal_traits::NoDealloc for OnionHopData{} pub struct DecodedOnionErrorPacket { pub(crate) hmac: [u8; 32], @@ -2010,9 +2017,9 @@ mod tests { target_value.append(&mut hex::decode("0000").unwrap()); } if initial_routing_sync { - target_value.append(&mut hex::decode("000108").unwrap()); + target_value.append(&mut hex::decode("000118").unwrap()); } else { - target_value.append(&mut hex::decode("0000").unwrap()); + target_value.append(&mut hex::decode("000110").unwrap()); } assert_eq!(encoded_value, target_value); }