@@ -165,6 +165,15 @@ impl PaymentDetails {
165165 update_if_necessary ! ( self . fee_paid_msat, fee_paid_msat_opt) ;
166166 }
167167
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+
168177 if let Some ( status) = update. status {
169178 update_if_necessary ! ( self . status, status) ;
170179 }
@@ -257,7 +266,14 @@ impl Readable for PaymentDetails {
257266
258267 if secret. is_some ( ) {
259268 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+ }
261277 } else {
262278 PaymentKind :: Bolt11 { hash, preimage, secret }
263279 }
@@ -346,6 +362,12 @@ pub enum PaymentKind {
346362 preimage : Option < PaymentPreimage > ,
347363 /// The secret used by the payment.
348364 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 > ,
349371 /// Limits applying to how much fee we allow an LSP to deduct from the payment amount.
350372 ///
351373 /// 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,
423445 } ,
424446 ( 4 , Bolt11Jit ) => {
425447 ( 0 , hash, required) ,
448+ ( 1 , counterparty_skimmed_fee_msat, option) ,
426449 ( 2 , preimage, option) ,
427450 ( 4 , secret, option) ,
428451 ( 6 , lsp_fee_limits, required) ,
@@ -501,6 +524,7 @@ pub(crate) struct PaymentDetailsUpdate {
501524 pub secret : Option < Option < PaymentSecret > > ,
502525 pub amount_msat : Option < Option < u64 > > ,
503526 pub fee_paid_msat : Option < Option < u64 > > ,
527+ pub counterparty_skimmed_fee_msat : Option < Option < u64 > > ,
504528 pub direction : Option < PaymentDirection > ,
505529 pub status : Option < PaymentStatus > ,
506530 pub confirmation_status : Option < ConfirmationStatus > ,
@@ -515,6 +539,7 @@ impl PaymentDetailsUpdate {
515539 secret : None ,
516540 amount_msat : None ,
517541 fee_paid_msat : None ,
542+ counterparty_skimmed_fee_msat : None ,
518543 direction : None ,
519544 status : None ,
520545 confirmation_status : None ,
@@ -538,13 +563,21 @@ impl From<&PaymentDetails> for PaymentDetailsUpdate {
538563 _ => None ,
539564 } ;
540565
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+
541573 Self {
542574 id : value. id ,
543575 hash : Some ( hash) ,
544576 preimage : Some ( preimage) ,
545577 secret : Some ( secret) ,
546578 amount_msat : Some ( value. amount_msat ) ,
547579 fee_paid_msat : Some ( value. fee_paid_msat ) ,
580+ counterparty_skimmed_fee_msat,
548581 direction : Some ( value. direction ) ,
549582 status : Some ( value. status ) ,
550583 confirmation_status,
@@ -841,10 +874,17 @@ mod tests {
841874 ) ;
842875
843876 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+ } => {
845884 assert_eq ! ( hash, h) ;
846885 assert_eq ! ( preimage, p) ;
847886 assert_eq ! ( secret, s) ;
887+ assert_eq ! ( None , c) ;
848888 assert_eq ! ( lsp_fee_limits, Some ( l) ) ;
849889 } ,
850890 _ => {
0 commit comments