#[cfg(not(feature = "fuzztarget"))]
pub(crate) fn new() -> LocalFeatures {
LocalFeatures {
- flags: vec![1 << 4],
+ flags: vec![2 | 1 << 5],
}
}
#[cfg(feature = "fuzztarget")]
pub fn new() -> LocalFeatures {
LocalFeatures {
- flags: vec![1 << 4],
+ flags: vec![2 | 1 << 5],
}
}
pub(crate) fn supports_data_loss_protect(&self) -> bool {
self.flags.len() > 0 && (self.flags[0] & 3) != 0
}
- pub(crate) fn requires_data_loss_protect(&self) -> bool {
- self.flags.len() > 0 && (self.flags[0] & 1) != 0
- }
-
pub(crate) fn initial_routing_sync(&self) -> bool {
self.flags.len() > 0 && (self.flags[0] & (1 << 3)) != 0
}
pub(crate) fn supports_upfront_shutdown_script(&self) -> bool {
self.flags.len() > 0 && (self.flags[0] & (3 << 4)) != 0
}
+ #[cfg(test)]
pub(crate) fn unset_upfront_shutdown_script(&mut self) {
- self.flags[0] ^= 1 << 4;
+ self.flags[0] ^= 1 << 5;
}
pub(crate) fn requires_unknown_bits(&self) -> bool {
pub(crate) contents: UnsignedChannelUpdate,
}
-/// Used to put an error message in a HandleError
+/// Used to put an error message in a LightningError
#[derive(Clone)]
pub enum ErrorAction {
/// The peer took some action which made us think they were useless. Disconnect them.
}
/// An Err type for failure to process messages.
-pub struct HandleError { //TODO: rename me
+pub struct LightningError {
/// A human-readable message describing the error
pub err: &'static str,
/// The action which should be taken against the offending peer.
- pub action: Option<ErrorAction>, //TODO: Make this required
+ pub action: ErrorAction,
}
/// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
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, their_local_features: LocalFeatures, msg: &OpenChannel) -> Result<(), HandleError>;
+ fn handle_open_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &OpenChannel) -> Result<(), LightningError>;
/// Handle an incoming accept_channel message from the given peer.
- fn handle_accept_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &AcceptChannel) -> Result<(), HandleError>;
+ fn handle_accept_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &AcceptChannel) -> Result<(), LightningError>;
/// Handle an incoming funding_created message from the given peer.
- fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &FundingCreated) -> Result<(), HandleError>;
+ fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &FundingCreated) -> Result<(), LightningError>;
/// Handle an incoming funding_signed message from the given peer.
- fn handle_funding_signed(&self, their_node_id: &PublicKey, msg: &FundingSigned) -> Result<(), HandleError>;
+ fn handle_funding_signed(&self, their_node_id: &PublicKey, msg: &FundingSigned) -> Result<(), LightningError>;
/// Handle an incoming funding_locked message from the given peer.
- fn handle_funding_locked(&self, their_node_id: &PublicKey, msg: &FundingLocked) -> Result<(), HandleError>;
+ fn handle_funding_locked(&self, their_node_id: &PublicKey, msg: &FundingLocked) -> Result<(), LightningError>;
// Channl close:
/// Handle an incoming shutdown message from the given peer.
- fn handle_shutdown(&self, their_node_id: &PublicKey, msg: &Shutdown) -> Result<(), HandleError>;
+ fn handle_shutdown(&self, their_node_id: &PublicKey, msg: &Shutdown) -> Result<(), LightningError>;
/// Handle an incoming closing_signed message from the given peer.
- fn handle_closing_signed(&self, their_node_id: &PublicKey, msg: &ClosingSigned) -> Result<(), HandleError>;
+ fn handle_closing_signed(&self, their_node_id: &PublicKey, msg: &ClosingSigned) -> Result<(), LightningError>;
// HTLC handling:
/// Handle an incoming update_add_htlc message from the given peer.
- fn handle_update_add_htlc(&self, their_node_id: &PublicKey, msg: &UpdateAddHTLC) -> Result<(), HandleError>;
+ fn handle_update_add_htlc(&self, their_node_id: &PublicKey, msg: &UpdateAddHTLC) -> Result<(), LightningError>;
/// Handle an incoming update_fulfill_htlc message from the given peer.
- fn handle_update_fulfill_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFulfillHTLC) -> Result<(), HandleError>;
+ fn handle_update_fulfill_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFulfillHTLC) -> Result<(), LightningError>;
/// Handle an incoming update_fail_htlc message from the given peer.
- fn handle_update_fail_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailHTLC) -> Result<(), HandleError>;
+ fn handle_update_fail_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailHTLC) -> Result<(), LightningError>;
/// Handle an incoming update_fail_malformed_htlc message from the given peer.
- fn handle_update_fail_malformed_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailMalformedHTLC) -> Result<(), HandleError>;
+ fn handle_update_fail_malformed_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailMalformedHTLC) -> Result<(), LightningError>;
/// Handle an incoming commitment_signed message from the given peer.
- fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<(), HandleError>;
+ fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<(), LightningError>;
/// Handle an incoming revoke_and_ack message from the given peer.
- fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK) -> Result<(), HandleError>;
+ fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK) -> Result<(), LightningError>;
/// Handle an incoming update_fee message from the given peer.
- fn handle_update_fee(&self, their_node_id: &PublicKey, msg: &UpdateFee) -> Result<(), HandleError>;
+ fn handle_update_fee(&self, their_node_id: &PublicKey, msg: &UpdateFee) -> Result<(), LightningError>;
// Channel-to-announce:
/// Handle an incoming announcement_signatures message from the given peer.
- fn handle_announcement_signatures(&self, their_node_id: &PublicKey, msg: &AnnouncementSignatures) -> Result<(), HandleError>;
+ fn handle_announcement_signatures(&self, their_node_id: &PublicKey, msg: &AnnouncementSignatures) -> Result<(), LightningError>;
// Connection loss/reestablish:
/// Indicates a connection to the peer failed/an existing connection was lost. If no connection
/// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
fn peer_connected(&self, their_node_id: &PublicKey);
/// Handle an incoming channel_reestablish message from the given peer.
- fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &ChannelReestablish) -> Result<(), HandleError>;
+ fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &ChannelReestablish) -> Result<(), LightningError>;
// Error:
/// Handle an incoming error message from the given peer.
pub trait RoutingMessageHandler : Send + Sync {
/// Handle an incoming node_announcement message, returning true if it should be forwarded on,
/// false or returning an Err otherwise.
- fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result<bool, HandleError>;
+ fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result<bool, LightningError>;
/// Handle a channel_announcement message, returning true if it should be forwarded on, false
/// or returning an Err otherwise.
- fn handle_channel_announcement(&self, msg: &ChannelAnnouncement) -> Result<bool, HandleError>;
+ fn handle_channel_announcement(&self, msg: &ChannelAnnouncement) -> Result<bool, LightningError>;
/// Handle an incoming channel_update message, returning true if it should be forwarded on,
/// false or returning an Err otherwise.
- fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result<bool, HandleError>;
+ fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result<bool, LightningError>;
/// 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
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],
}
}
-impl fmt::Debug for HandleError {
+impl fmt::Debug for LightningError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(self.err)
}
target_value.append(&mut hex::decode("0000").unwrap());
}
if initial_routing_sync {
- target_value.append(&mut hex::decode("000118").unwrap());
+ target_value.append(&mut hex::decode("00012a").unwrap());
} else {
- target_value.append(&mut hex::decode("000110").unwrap());
+ target_value.append(&mut hex::decode("000122").unwrap());
}
assert_eq!(encoded_value, target_value);
}