]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #1143 from TheBlueMatt/2021-10-no-payment-id-leaks
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 12 Nov 2021 17:59:18 +0000 (17:59 +0000)
committerGitHub <noreply@github.com>
Fri, 12 Nov 2021 17:59:18 +0000 (17:59 +0000)
Fix a minor memory leak on PermanentFailure mon errs when sending

1  2 
lightning/src/ln/channelmanager.rs

index a5f84abfdb3e2865505db43149fbdebde96ee71c,444d443facf98dbb2915172a33c754ea42abb0fe..5aebf3dbf5c334f19bcc8c4de00d5db10b7621d3
@@@ -2261,20 -2251,11 +2265,23 @@@ impl<Signer: Sign, M: Deref, T: Deref, 
                        }
                }
                if has_err && has_ok {
 -                      Err(PaymentSendFailure::PartialFailure(results))
 +                      Err(PaymentSendFailure::PartialFailure {
 +                              results,
 +                              payment_id,
 +                              failed_paths_retry: if pending_amt_unsent != 0 {
 +                                      if let Some(payee) = &route.payee {
 +                                              Some(RouteParameters {
 +                                                      payee: payee.clone(),
 +                                                      final_value_msat: pending_amt_unsent,
 +                                                      final_cltv_expiry_delta: max_unsent_cltv_delta,
 +                                              })
 +                                      } else { None }
 +                              } else { None },
 +                      })
                } else if has_err {
+                       // If we failed to send any paths, we shouldn't have inserted the new PaymentId into
+                       // our `pending_outbound_payments` map at all.
+                       debug_assert!(self.pending_outbound_payments.lock().unwrap().get(&payment_id).is_none());
                        Err(PaymentSendFailure::AllFailedRetrySafe(results.drain(..).map(|r| r.unwrap_err()).collect()))
                } else {
                        Ok(payment_id)