X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fmsgs.rs;h=4cff6256f83f9176460d80f23044d93036114b7a;hb=608cf1c89db01f9cf612516a88a3f77f1f48bc52;hp=110e2f336adb7e112fe5104c67a35db8aedf22e7;hpb=3609ba5c208fb5955429a33ca5424a488643337a;p=rust-lightning diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index 110e2f33..4cff6256 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -29,6 +29,8 @@ use std::result::Result; use util::{byte_utils, events}; use util::ser::{Readable, Writeable, Writer}; +use ln::channelmanager::{PaymentPreimage, PaymentHash}; + /// An error in decoding a message or struct. #[derive(Debug)] pub enum DecodeError { @@ -151,6 +153,7 @@ pub struct Init { } /// An error message to be sent or received from a peer +#[derive(Clone)] pub struct ErrorMessage { pub(crate) channel_id: [u8; 32], pub(crate) data: String, @@ -235,14 +238,14 @@ pub struct FundingLocked { } /// A shutdown message to be sent or received from a peer -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct Shutdown { pub(crate) channel_id: [u8; 32], pub(crate) scriptpubkey: Script, } /// A closing_signed message to be sent or received from a peer -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct ClosingSigned { pub(crate) channel_id: [u8; 32], pub(crate) fee_satoshis: u64, @@ -255,7 +258,7 @@ pub struct UpdateAddHTLC { pub(crate) channel_id: [u8; 32], pub(crate) htlc_id: u64, pub(crate) amount_msat: u64, - pub(crate) payment_hash: [u8; 32], + pub(crate) payment_hash: PaymentHash, pub(crate) cltv_expiry: u32, pub(crate) onion_routing_packet: OnionPacket, } @@ -265,7 +268,7 @@ pub struct UpdateAddHTLC { pub struct UpdateFulfillHTLC { pub(crate) channel_id: [u8; 32], pub(crate) htlc_id: u64, - pub(crate) payment_preimage: [u8; 32], + pub(crate) payment_preimage: PaymentPreimage, } /// An update_fail_htlc message to be sent or received from a peer @@ -381,6 +384,7 @@ impl NetAddress { } } +#[derive(Clone)] // Only exposed as broadcast of node_announcement should be filtered by node_id /// The unsigned part of a node_announcement pub struct UnsignedNodeAnnouncement { @@ -397,6 +401,7 @@ pub struct UnsignedNodeAnnouncement { pub(crate) excess_address_data: Vec, pub(crate) excess_data: Vec, } +#[derive(Clone)] /// A node_announcement message to be sent or received from a peer pub struct NodeAnnouncement { pub(crate) signature: Signature, @@ -448,6 +453,7 @@ pub struct ChannelUpdate { } /// Used to put an error message in a HandleError +#[derive(Clone)] pub enum ErrorAction { /// The peer took some action which made us think they were useless. Disconnect them. DisconnectPeer { @@ -486,6 +492,7 @@ pub struct CommitmentUpdate { /// The information we received from a peer along the route of a payment we originated. This is /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map. +#[derive(Clone)] pub enum HTLCFailChannelUpdate { /// We received an error which included a full ChannelUpdate message. ChannelUpdateMessage { @@ -585,6 +592,14 @@ pub trait RoutingMessageHandler : Send + Sync { fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result; /// Handle some updates to the route graph that we learned due to an outbound failed payment. fn handle_htlc_fail_channel_update(&self, update: &HTLCFailChannelUpdate); + /// Gets a subset of the channel announcements and updates required to dump our routing table + /// to a remote node, starting at the short_channel_id indicated by starting_point and + /// including batch_amount entries. + fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(ChannelAnnouncement, ChannelUpdate, ChannelUpdate)>; + /// Gets a subset of the node announcements required to dump our routing table to a remote node, + /// 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; } pub(crate) struct OnionRealm0HopData {