File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1057,8 +1057,12 @@ impl OutboundPayments {
1057
1057
let mut has_ok = false ;
1058
1058
let mut has_err = false ;
1059
1059
let mut pending_amt_unsent = 0 ;
1060
+ let mut total_ok_fees_msat = 0 ;
1060
1061
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
+ }
1062
1066
if res. is_err ( ) { has_err = true ; }
1063
1067
if let & Err ( APIError :: MonitorUpdateInProgress ) = res {
1064
1068
// MonitorUpdateInProgress is inherently unsafe to retry, so we call it a
@@ -1075,8 +1079,14 @@ impl OutboundPayments {
1075
1079
payment_id,
1076
1080
failed_paths_retry : if pending_amt_unsent != 0 {
1077
1081
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
+
1078
1088
Some ( RouteParameters {
1079
- payment_params : payment_params . clone ( ) ,
1089
+ payment_params,
1080
1090
final_value_msat : pending_amt_unsent,
1081
1091
} )
1082
1092
} else { None }
You can’t perform that action at this time.
0 commit comments