File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1057,8 +1057,12 @@ impl OutboundPayments {
10571057 let mut has_ok = false ;
10581058 let mut has_err = false ;
10591059 let mut pending_amt_unsent = 0 ;
1060+ let mut total_ok_fees_msat = 0 ;
10601061 for ( res, path) in results. iter ( ) . zip ( route. paths . iter ( ) ) {
1061- if res. is_ok ( ) { has_ok = true ; }
1062+ if res. is_ok ( ) {
1063+ has_ok = true ;
1064+ total_ok_fees_msat += path. fee_msat ( ) ;
1065+ }
10621066 if res. is_err ( ) { has_err = true ; }
10631067 if let & Err ( APIError :: MonitorUpdateInProgress ) = res {
10641068 // MonitorUpdateInProgress is inherently unsafe to retry, so we call it a
@@ -1075,8 +1079,14 @@ impl OutboundPayments {
10751079 payment_id,
10761080 failed_paths_retry : if pending_amt_unsent != 0 {
10771081 if let Some ( payment_params) = & route. payment_params {
1082+ let mut payment_params = payment_params. clone ( ) ;
1083+ // We calculate the leftover fee budget we're allowed to spend by
1084+ // subtracting the used fee from the total fee budget.
1085+ payment_params. max_total_routing_fee_msat = payment_params
1086+ . max_total_routing_fee_msat . map ( |m| m. saturating_sub ( total_ok_fees_msat) ) ;
1087+
10781088 Some ( RouteParameters {
1079- payment_params : payment_params . clone ( ) ,
1089+ payment_params,
10801090 final_value_msat : pending_amt_unsent,
10811091 } )
10821092 } else { None }
You can’t perform that action at this time.
0 commit comments