Expose `skimmed_fee_msat` in `PaymentForwarded`
[rust-lightning] / lightning / src / events / mod.rs
index 201431bbed70fde3df320ba09c9418e742dbf77a..801e8695c8194f9671c9094dd9efc3730f21963c 100644 (file)
@@ -797,6 +797,20 @@ pub enum Event {
                /// `PaymentForwarded` events are generated for the same payment iff `total_fee_earned_msat` is
                /// `None`.
                total_fee_earned_msat: Option<u64>,
+               /// The share of the total fee, in milli-satoshis, which was withheld in addition to the
+               /// forwarding fee.
+               ///
+               /// This will only be `Some` if we forwarded an intercepted HTLC with less than the
+               /// expected amount. This means our counterparty accepted to receive less than the invoice
+               /// amount, e.g., by claiming the payment featuring a corresponding
+               /// [`PaymentClaimable::counterparty_skimmed_fee_msat`].
+               ///
+               /// Will also always be `None` for events serialized with LDK prior to version 0.0.122.
+               ///
+               /// The caveat described above the `total_fee_earned_msat` field applies here as well.
+               ///
+               /// [`PaymentClaimable::counterparty_skimmed_fee_msat`]: Self::PaymentClaimable::counterparty_skimmed_fee_msat
+               skimmed_fee_msat: Option<u64>,
                /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
                /// transaction.
                claim_from_onchain_tx: bool,
@@ -1084,7 +1098,7 @@ impl Writeable for Event {
                        }
                        &Event::PaymentForwarded {
                                total_fee_earned_msat, prev_channel_id, claim_from_onchain_tx,
-                               next_channel_id, outbound_amount_forwarded_msat
+                               next_channel_id, outbound_amount_forwarded_msat, skimmed_fee_msat,
                        } => {
                                7u8.write(writer)?;
                                write_tlv_fields!(writer, {
@@ -1093,6 +1107,7 @@ impl Writeable for Event {
                                        (2, claim_from_onchain_tx, required),
                                        (3, next_channel_id, option),
                                        (5, outbound_amount_forwarded_msat, option),
+                                       (7, skimmed_fee_msat, option),
                                });
                        },
                        &Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
@@ -1389,16 +1404,18 @@ impl MaybeReadable for Event {
                                        let mut claim_from_onchain_tx = false;
                                        let mut next_channel_id = None;
                                        let mut outbound_amount_forwarded_msat = None;
+                                       let mut skimmed_fee_msat = None;
                                        read_tlv_fields!(reader, {
                                                (0, total_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),
+                                               (7, skimmed_fee_msat, option),
                                        });
                                        Ok(Some(Event::PaymentForwarded {
                                                total_fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
-                                               outbound_amount_forwarded_msat
+                                               outbound_amount_forwarded_msat, skimmed_fee_msat,
                                        }))
                                };
                                f()