X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fevents.rs;h=5953ee68940e61472f4e2acc2665dd89a0f71c98;hb=257a6f3e48b2e36968551dcc0e0421c660ddc4a8;hp=f35dc14e03555bed83d94e48c9702e6d50a36bc9;hpb=62edee568985e3362bd1609c6089d05428023925;p=rust-lightning diff --git a/lightning/src/util/events.rs b/lightning/src/util/events.rs index f35dc14e..5953ee68 100644 --- a/lightning/src/util/events.rs +++ b/lightning/src/util/events.rs @@ -29,7 +29,7 @@ use bitcoin::Transaction; use bitcoin::blockdata::script::Script; use bitcoin::hashes::Hash; use bitcoin::hashes::sha256::Hash as Sha256; -use bitcoin::secp256k1::key::PublicKey; +use bitcoin::secp256k1::PublicKey; use io; use prelude::*; use core::time::Duration; @@ -100,12 +100,11 @@ pub enum ClosureReason { /// A developer-readable error message which we generated. err: String, }, - /// The `PeerManager` informed us that we've disconnected from the peer. We close channels - /// if the `PeerManager` informed us that it is unlikely we'll be able to connect to the - /// peer again in the future or if the peer disconnected before we finished negotiating - /// the channel open. The first case may be caused by incompatible features which our - /// counterparty, or we, require. - //TODO: split between PeerUnconnectable/PeerDisconnected ? + /// The peer disconnected prior to funding completing. In this case the spec mandates that we + /// forget the channel entirely - we can attempt again if the peer reconnects. + /// + /// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the + /// peer because of mutual incompatibility between us and our channel counterparty. DisconnectedPeer, /// Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than /// the ChannelManager deserialized. @@ -363,9 +362,12 @@ pub enum Event { /// This event is generated when a payment has been successfully forwarded through us and a /// forwarding fee earned. PaymentForwarded { - /// The channel between the source node and us. Optional because versions prior to 0.0.107 - /// do not serialize this field. - source_channel_id: Option<[u8; 32]>, + /// The incoming channel between the previous node and us. This is only `None` for events + /// generated or serialized by versions prior to 0.0.107. + prev_channel_id: Option<[u8; 32]>, + /// The outgoing channel between the next node and us. This is only `None` for events + /// generated or serialized by versions prior to 0.0.107. + next_channel_id: Option<[u8; 32]>, /// The fee, in milli-satoshis, which was earned as a result of the payment. /// /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC @@ -523,12 +525,13 @@ impl Writeable for Event { (0, VecWriteWrapper(outputs), required), }); }, - &Event::PaymentForwarded { fee_earned_msat, source_channel_id, claim_from_onchain_tx } => { + &Event::PaymentForwarded { fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id } => { 7u8.write(writer)?; write_tlv_fields!(writer, { (0, fee_earned_msat, option), - (1, source_channel_id, option), + (1, prev_channel_id, option), (2, claim_from_onchain_tx, required), + (3, next_channel_id, option), }); }, &Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason } => { @@ -688,14 +691,16 @@ impl MaybeReadable for Event { 7u8 => { let f = || { let mut fee_earned_msat = None; - let mut source_channel_id = None; + let mut prev_channel_id = None; let mut claim_from_onchain_tx = false; + let mut next_channel_id = None; read_tlv_fields!(reader, { (0, fee_earned_msat, option), - (1, source_channel_id, option), + (1, prev_channel_id, option), (2, claim_from_onchain_tx, required), + (3, next_channel_id, option), }); - Ok(Some(Event::PaymentForwarded { fee_earned_msat, source_channel_id, claim_from_onchain_tx })) + Ok(Some(Event::PaymentForwarded { fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id })) }; f() },