}
/// Used to put an error message in a HandleError
-pub enum ErrorMessage {
+pub enum ErrorAction {
+ /// Indicates an inbound HTLC add resulted in a failure, and the UpdateFailHTLC provided in msg
+ /// should be sent back to the sender.
UpdateFailHTLC {
msg: UpdateFailHTLC
},
+ /// The peer took some action which made us think they were useless. Disconnect them.
DisconnectPeer {},
}
pub struct HandleError { //TODO: rename me
pub err: &'static str,
- pub msg: Option<ErrorMessage>, //TODO: Move into an Action enum and require it!
+ pub msg: Option<ErrorAction>, //TODO: Make this required and rename it
+}
+
+/// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
+/// transaction updates if they were pending.
+pub struct CommitmentUpdate {
+ pub update_add_htlcs: Vec<UpdateAddHTLC>,
+ pub update_fulfill_htlcs: Vec<UpdateFulfillHTLC>,
+ pub update_fail_htlcs: Vec<UpdateFailHTLC>,
+ pub commitment_signed: CommitmentSigned,
}
/// A trait to describe an object which can receive channel messages. Messages MAY be called in
fn handle_update_fulfill_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFulfillHTLC) -> Result<(), HandleError>;
fn handle_update_fail_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailHTLC) -> Result<(), HandleError>;
fn handle_update_fail_malformed_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailMalformedHTLC) -> Result<(), HandleError>;
- fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<RevokeAndACK, HandleError>;
- fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK) -> Result<Option<(Vec<UpdateAddHTLC>, CommitmentSigned)>, HandleError>;
+ fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<(RevokeAndACK, Option<CommitmentSigned>), HandleError>;
+ fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK) -> Result<Option<CommitmentUpdate>, HandleError>;
fn handle_update_fee(&self, their_node_id: &PublicKey, msg: &UpdateFee) -> Result<(), HandleError>;
// Channel-to-announce:
fn handle_announcement_signatures(&self, their_node_id: &PublicKey, msg: &AnnouncementSignatures) -> Result<(), HandleError>;
+
+ // Informational:
+ /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
+ /// is believed to be possible in the future (eg they're sending us messages we don't
+ /// understand or indicate they require unknown feature bits), no_connection_possible is set
+ /// and any outstanding channels should be failed.
+ fn peer_disconnected(&self, their_node_id: &PublicKey, no_connection_possible: bool);
}
pub trait RoutingMessageHandler {