@@ -387,8 +387,24 @@ pub enum Event {
387
387
///
388
388
/// Payments received on LDK versions prior to 0.0.115 will have this field unset.
389
389
onion_fields : Option < RecipientOnionFields > ,
390
- /// The value, in thousandths of a satoshi, that this payment is for.
390
+ /// The value, in thousandths of a satoshi, that this payment is claimable for.
391
+ ///
392
+ /// May be less than the invoice amount if [`ChannelConfig::accept_underpaying_htlcs`] is set
393
+ /// and the previous hop took an extra fee.
394
+ ///
395
+ /// # Note
396
+ /// If [`ChannelConfig::accept_underpaying_htlcs`] is set and you claim without verifying this
397
+ /// field, you may lose money!
398
+ ///
399
+ /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
391
400
amount_msat : u64 ,
401
+ /// The value, in thousands of a satoshi, that was skimmed off of this payment as an extra fee
402
+ /// taken by our channel counterparty.
403
+ ///
404
+ /// Will always be 0 unless [`ChannelConfig::accept_underpaying_htlcs`] is set.
405
+ ///
406
+ /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
407
+ counterparty_skimmed_fee_msat : u64 ,
392
408
/// Information for claiming this received payment, based on whether the purpose of the
393
409
/// payment is to pay an invoice or to send a spontaneous payment.
394
410
purpose : PaymentPurpose ,
@@ -832,8 +848,8 @@ impl Writeable for Event {
832
848
// We never write out FundingGenerationReady events as, upon disconnection, peers
833
849
// drop any channels which have not yet exchanged funding_signed.
834
850
} ,
835
- & Event :: PaymentClaimable { ref payment_hash, ref amount_msat, ref purpose ,
836
- ref receiver_node_id, ref via_channel_id, ref via_user_channel_id,
851
+ & Event :: PaymentClaimable { ref payment_hash, ref amount_msat, counterparty_skimmed_fee_msat ,
852
+ ref purpose , ref receiver_node_id, ref via_channel_id, ref via_user_channel_id,
837
853
ref claim_deadline, ref onion_fields
838
854
} => {
839
855
1u8 . write ( writer) ?;
@@ -848,6 +864,8 @@ impl Writeable for Event {
848
864
payment_preimage = Some ( * preimage) ;
849
865
}
850
866
}
867
+ let skimmed_fee_opt = if counterparty_skimmed_fee_msat == 0 { None }
868
+ else { Some ( counterparty_skimmed_fee_msat) } ;
851
869
write_tlv_fields ! ( writer, {
852
870
( 0 , payment_hash, required) ,
853
871
( 1 , receiver_node_id, option) ,
@@ -859,6 +877,7 @@ impl Writeable for Event {
859
877
( 7 , claim_deadline, option) ,
860
878
( 8 , payment_preimage, option) ,
861
879
( 9 , onion_fields, option) ,
880
+ ( 10 , skimmed_fee_opt, option) ,
862
881
} ) ;
863
882
} ,
864
883
& Event :: PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
@@ -1058,6 +1077,7 @@ impl MaybeReadable for Event {
1058
1077
let mut payment_preimage = None ;
1059
1078
let mut payment_secret = None ;
1060
1079
let mut amount_msat = 0 ;
1080
+ let mut counterparty_skimmed_fee_msat_opt = None ;
1061
1081
let mut receiver_node_id = None ;
1062
1082
let mut _user_payment_id = None :: < u64 > ; // For compatibility with 0.0.103 and earlier
1063
1083
let mut via_channel_id = None ;
@@ -1075,6 +1095,7 @@ impl MaybeReadable for Event {
1075
1095
( 7 , claim_deadline, option) ,
1076
1096
( 8 , payment_preimage, option) ,
1077
1097
( 9 , onion_fields, option) ,
1098
+ ( 10 , counterparty_skimmed_fee_msat_opt, option) ,
1078
1099
} ) ;
1079
1100
let purpose = match payment_secret {
1080
1101
Some ( secret) => PaymentPurpose :: InvoicePayment {
@@ -1088,6 +1109,7 @@ impl MaybeReadable for Event {
1088
1109
receiver_node_id,
1089
1110
payment_hash,
1090
1111
amount_msat,
1112
+ counterparty_skimmed_fee_msat : counterparty_skimmed_fee_msat_opt. unwrap_or ( 0 ) ,
1091
1113
purpose,
1092
1114
via_channel_id,
1093
1115
via_user_channel_id,
0 commit comments