X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fmsgs.rs;h=5939c09b164c4d67606b7806ef7e809c50c5334d;hb=374ea1f05e301b7f2c47781ad4f7a3ac5ac909fd;hp=312fea206e44d5702f02e4065e7d260f034381bf;hpb=24fd566567320b4d78fa868cce873bd733e30ce5;p=rust-lightning diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index 312fea20..5939c09b 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -342,16 +342,28 @@ pub struct ChannelUpdate { } /// 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, //TODO: Move into an Action enum and require it! + pub msg: Option, //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, + pub update_fulfill_htlcs: Vec, + pub update_fail_htlcs: Vec, + pub commitment_signed: CommitmentSigned, } /// A trait to describe an object which can receive channel messages. Messages MAY be called in @@ -374,13 +386,20 @@ pub trait ChannelMessageHandler : events::EventsProvider { 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; - fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK) -> Result, CommitmentSigned)>, HandleError>; + fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<(RevokeAndACK, Option), HandleError>; + fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK) -> Result, 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 {