@@ -165,6 +165,15 @@ impl PaymentDetails {
165
165
update_if_necessary ! ( self . fee_paid_msat, fee_paid_msat_opt) ;
166
166
}
167
167
168
+ if let Some ( skimmed_fee_msat) = update. counterparty_skimmed_fee_msat {
169
+ match self . kind {
170
+ PaymentKind :: Bolt11Jit { ref mut counterparty_skimmed_fee_msat, .. } => {
171
+ update_if_necessary ! ( * counterparty_skimmed_fee_msat, skimmed_fee_msat) ;
172
+ } ,
173
+ _ => { } ,
174
+ }
175
+ }
176
+
168
177
if let Some ( status) = update. status {
169
178
update_if_necessary ! ( self . status, status) ;
170
179
}
@@ -257,7 +266,14 @@ impl Readable for PaymentDetails {
257
266
258
267
if secret. is_some ( ) {
259
268
if let Some ( lsp_fee_limits) = lsp_fee_limits {
260
- PaymentKind :: Bolt11Jit { hash, preimage, secret, lsp_fee_limits }
269
+ let counterparty_skimmed_fee_msat = None ;
270
+ PaymentKind :: Bolt11Jit {
271
+ hash,
272
+ preimage,
273
+ secret,
274
+ counterparty_skimmed_fee_msat,
275
+ lsp_fee_limits,
276
+ }
261
277
} else {
262
278
PaymentKind :: Bolt11 { hash, preimage, secret }
263
279
}
@@ -346,6 +362,12 @@ pub enum PaymentKind {
346
362
preimage : Option < PaymentPreimage > ,
347
363
/// The secret used by the payment.
348
364
secret : Option < PaymentSecret > ,
365
+ /// The value, in thousands of a satoshi, that was deducted off of this payment as an extra
366
+ /// fee taken by our channel counterparty.
367
+ ///
368
+ /// Will only be `Some` once we received the payment. Will always be `None` for LDK Node
369
+ /// v0.4 and prior.
370
+ counterparty_skimmed_fee_msat : Option < u64 > ,
349
371
/// Limits applying to how much fee we allow an LSP to deduct from the payment amount.
350
372
///
351
373
/// Allowing them to deduct this fee from the first inbound payment will pay for the LSP's
@@ -423,6 +445,7 @@ impl_writeable_tlv_based_enum!(PaymentKind,
423
445
} ,
424
446
( 4 , Bolt11Jit ) => {
425
447
( 0 , hash, required) ,
448
+ ( 1 , counterparty_skimmed_fee_msat, option) ,
426
449
( 2 , preimage, option) ,
427
450
( 4 , secret, option) ,
428
451
( 6 , lsp_fee_limits, required) ,
@@ -501,6 +524,7 @@ pub(crate) struct PaymentDetailsUpdate {
501
524
pub secret : Option < Option < PaymentSecret > > ,
502
525
pub amount_msat : Option < Option < u64 > > ,
503
526
pub fee_paid_msat : Option < Option < u64 > > ,
527
+ pub counterparty_skimmed_fee_msat : Option < Option < u64 > > ,
504
528
pub direction : Option < PaymentDirection > ,
505
529
pub status : Option < PaymentStatus > ,
506
530
pub confirmation_status : Option < ConfirmationStatus > ,
@@ -515,6 +539,7 @@ impl PaymentDetailsUpdate {
515
539
secret : None ,
516
540
amount_msat : None ,
517
541
fee_paid_msat : None ,
542
+ counterparty_skimmed_fee_msat : None ,
518
543
direction : None ,
519
544
status : None ,
520
545
confirmation_status : None ,
@@ -538,13 +563,21 @@ impl From<&PaymentDetails> for PaymentDetailsUpdate {
538
563
_ => None ,
539
564
} ;
540
565
566
+ let counterparty_skimmed_fee_msat = match value. kind {
567
+ PaymentKind :: Bolt11Jit { counterparty_skimmed_fee_msat, .. } => {
568
+ Some ( counterparty_skimmed_fee_msat)
569
+ } ,
570
+ _ => None ,
571
+ } ;
572
+
541
573
Self {
542
574
id : value. id ,
543
575
hash : Some ( hash) ,
544
576
preimage : Some ( preimage) ,
545
577
secret : Some ( secret) ,
546
578
amount_msat : Some ( value. amount_msat ) ,
547
579
fee_paid_msat : Some ( value. fee_paid_msat ) ,
580
+ counterparty_skimmed_fee_msat,
548
581
direction : Some ( value. direction ) ,
549
582
status : Some ( value. status ) ,
550
583
confirmation_status,
@@ -841,10 +874,17 @@ mod tests {
841
874
) ;
842
875
843
876
match bolt11_jit_decoded. kind {
844
- PaymentKind :: Bolt11Jit { hash : h, preimage : p, secret : s, lsp_fee_limits : l } => {
877
+ PaymentKind :: Bolt11Jit {
878
+ hash : h,
879
+ preimage : p,
880
+ secret : s,
881
+ counterparty_skimmed_fee_msat : c,
882
+ lsp_fee_limits : l,
883
+ } => {
845
884
assert_eq ! ( hash, h) ;
846
885
assert_eq ! ( preimage, p) ;
847
886
assert_eq ! ( secret, s) ;
887
+ assert_eq ! ( None , c) ;
848
888
assert_eq ! ( lsp_fee_limits, Some ( l) ) ;
849
889
} ,
850
890
_ => {
0 commit comments