File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -346,10 +346,13 @@ pub struct Route {
346
346
impl Route {
347
347
/// Returns the total amount of fees paid on this [`Route`].
348
348
///
349
- /// This doesn't include any extra payment made to the recipient, which can happen in excess of
350
- /// the amount passed to [`find_route`]'s `route_params.final_value_msat`.
349
+ /// For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to
350
+ /// the recipient, which can happen in excess of the amount passed to [`find_route`] via
351
+ /// [`RouteParameters::final_value_msat`].
351
352
pub fn get_total_fees ( & self ) -> u64 {
352
- self . paths . iter ( ) . map ( |path| path. fee_msat ( ) ) . sum ( )
353
+ let overpaid_value_msat = self . route_params . as_ref ( )
354
+ . map_or ( 0 , |p| self . get_total_amount ( ) . saturating_sub ( p. final_value_msat ) ) ;
355
+ overpaid_value_msat + self . paths . iter ( ) . map ( |path| path. fee_msat ( ) ) . sum :: < u64 > ( )
353
356
}
354
357
355
358
/// Returns the total amount paid on this [`Route`], excluding the fees. Might be more than
You can’t perform that action at this time.
0 commit comments