/// An init message to be sent or received from a peer
pub struct Init {
+ #[cfg(not(feature = "fuzztarget"))]
pub(crate) features: InitFeatures,
+ #[cfg(feature = "fuzztarget")]
+ pub features: InitFeatures,
}
/// An error message to be sent or received from a peer
fn peer_disconnected(&self, their_node_id: &PublicKey, no_connection_possible: bool);
/// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
- fn peer_connected(&self, their_node_id: &PublicKey);
+ fn peer_connected(&self, their_node_id: &PublicKey, msg: &Init);
/// Handle an incoming channel_reestablish message from the given peer.
fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &ChannelReestablish);
/// starting at the node *after* the provided publickey and including batch_amount entries.
/// If None is provided for starting_point, we start at the first node.
fn get_next_node_announcements(&self, starting_point: Option<&PublicKey>, batch_amount: u8) -> Vec<NodeAnnouncement>;
-}
-
-pub(crate) struct OnionRealm0HopData {
- pub(crate) short_channel_id: u64,
- pub(crate) amt_to_forward: u64,
- pub(crate) outgoing_cltv_value: u32,
- // 12 bytes of 0-padding
+ /// Returns whether a full sync should be requested from a peer.
+ fn should_request_full_sync(&self, node_id: &PublicKey) -> bool;
}
mod fuzzy_internal_msgs {
// These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize
// them from untrusted input):
- use super::OnionRealm0HopData;
+ pub(crate) enum OnionHopDataFormat {
+ Legacy, // aka Realm-0
+ }
+
pub struct OnionHopData {
- pub(crate) realm: u8,
- pub(crate) data: OnionRealm0HopData,
- pub(crate) hmac: [u8; 32],
+ pub(crate) format: OnionHopDataFormat,
+ pub(crate) short_channel_id: u64,
+ pub(crate) amt_to_forward: u64,
+ pub(crate) outgoing_cltv_value: u32,
+ // 12 bytes of 0-padding
}
pub struct DecodedOnionErrorPacket {
onion_routing_packet
});
-impl Writeable for OnionRealm0HopData {
+impl Writeable for OnionHopData {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
- w.size_hint(32);
+ w.size_hint(33);
+ match self.format {
+ OnionHopDataFormat::Legacy => 0u8.write(w)?,
+ }
self.short_channel_id.write(w)?;
self.amt_to_forward.write(w)?;
self.outgoing_cltv_value.write(w)?;
}
}
-impl<R: Read> Readable<R> for OnionRealm0HopData {
- fn read(r: &mut R) -> Result<Self, DecodeError> {
- Ok(OnionRealm0HopData {
- short_channel_id: Readable::read(r)?,
- amt_to_forward: Readable::read(r)?,
- outgoing_cltv_value: {
- let v: u32 = Readable::read(r)?;
- r.read_exact(&mut [0; 12])?;
- v
- }
- })
- }
-}
-
-impl Writeable for OnionHopData {
- fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
- w.size_hint(65);
- self.realm.write(w)?;
- self.data.write(w)?;
- self.hmac.write(w)?;
- Ok(())
- }
-}
-
impl<R: Read> Readable<R> for OnionHopData {
fn read(r: &mut R) -> Result<Self, DecodeError> {
Ok(OnionHopData {
- realm: {
+ format: {
let r: u8 = Readable::read(r)?;
if r != 0 {
return Err(DecodeError::UnknownVersion);
}
- r
+ OnionHopDataFormat::Legacy
+ },
+ short_channel_id: Readable::read(r)?,
+ amt_to_forward: Readable::read(r)?,
+ outgoing_cltv_value: {
+ let v: u32 = Readable::read(r)?;
+ r.read_exact(&mut [0; 12])?;
+ v
},
- data: Readable::read(r)?,
- hmac: Readable::read(r)?,
})
}
}