add outbound_amount_forwarded_msat field to PaymentForwarded event
[rust-lightning] / lightning / src / events / mod.rs
index 4f3b55804c72753a8bcdaba64bb0a327547e7944..a96d36b645312e6efe854a8ddb4f272db3b94532 100644 (file)
@@ -230,7 +230,7 @@ pub enum HTLCDestination {
        ///
        /// Some of the reasons may include:
        /// * HTLC Timeouts
-       /// * Expected MPP amount to claim does not equal HTLC total
+       /// * Expected MPP amount has already been reached
        /// * Claimable amount does not match expected amount
        FailedPayment {
                /// The payment hash of the payment we attempted to process.
@@ -603,6 +603,10 @@ pub enum Event {
                /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
                /// transaction.
                claim_from_onchain_tx: bool,
+               /// The final amount forwarded, in milli-satoshis, after the fee is deducted.
+               ///
+               /// The caveat described above the `fee_earned_msat` field applies here as well.
+               outbound_amount_forwarded_msat: Option<u64>,
        },
        /// Used to indicate that a channel with the given `channel_id` is ready to
        /// be used. This event is emitted either when the funding transaction has been confirmed
@@ -712,7 +716,7 @@ pub enum Event {
        /// * Insufficient capacity in the outbound channel
        /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes
        /// * When an unknown SCID is requested for forwarding a payment.
-       /// * Claiming an amount for an MPP payment that exceeds the HTLC total
+       /// * Expected MPP amount has already been reached
        /// * The HTLC has timed out
        ///
        /// This event, however, does not get generated if an HTLC fails to meet the forwarding
@@ -820,13 +824,17 @@ impl Writeable for Event {
                                        (8, expected_outbound_amount_msat, required),
                                });
                        }
-                       &Event::PaymentForwarded { fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id } => {
+                       &Event::PaymentForwarded {
+                               fee_earned_msat, prev_channel_id, claim_from_onchain_tx,
+                               next_channel_id, outbound_amount_forwarded_msat
+                       } => {
                                7u8.write(writer)?;
                                write_tlv_fields!(writer, {
                                        (0, fee_earned_msat, option),
                                        (1, prev_channel_id, option),
                                        (2, claim_from_onchain_tx, required),
                                        (3, next_channel_id, option),
+                                       (5, outbound_amount_forwarded_msat, option),
                                });
                        },
                        &Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason } => {
@@ -1078,13 +1086,18 @@ impl MaybeReadable for Event {
                                        let mut prev_channel_id = None;
                                        let mut claim_from_onchain_tx = false;
                                        let mut next_channel_id = None;
+                                       let mut outbound_amount_forwarded_msat = None;
                                        read_tlv_fields!(reader, {
                                                (0, fee_earned_msat, option),
                                                (1, prev_channel_id, option),
                                                (2, claim_from_onchain_tx, required),
                                                (3, next_channel_id, option),
+                                               (5, outbound_amount_forwarded_msat, option),
                                        });
-                                       Ok(Some(Event::PaymentForwarded { fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id }))
+                                       Ok(Some(Event::PaymentForwarded {
+                                               fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
+                                               outbound_amount_forwarded_msat
+                                       }))
                                };
                                f()
                        },