@@ -5506,22 +5506,11 @@ where
55065506 fn send_payment_for_static_invoice(
55075507 &self, payment_id: PaymentId,
55085508 ) -> Result<(), Bolt12PaymentError> {
5509- let best_block_height = self.best_block.read().unwrap().height;
55105509 let mut res = Ok(());
5510+ let first_hops = self.list_usable_channels();
55115511 PersistenceNotifierGuard::optionally_notify(self, || {
5512- let outbound_pmts_res = self.pending_outbound_payments.send_payment_for_static_invoice(
5513- payment_id,
5514- &self.router,
5515- self.list_usable_channels(),
5516- || self.compute_inflight_htlcs(),
5517- &self.entropy_source,
5518- &self.node_signer,
5519- &self,
5520- &self.secp_ctx,
5521- best_block_height,
5522- &self.pending_events,
5523- |args| self.send_payment_along_path(args),
5524- );
5512+ let outbound_pmts_res =
5513+ self.send_payment_for_static_invoice_no_persist(payment_id, first_hops);
55255514 match outbound_pmts_res {
55265515 Err(Bolt12PaymentError::UnexpectedInvoice)
55275516 | Err(Bolt12PaymentError::DuplicateInvoice) => {
@@ -5537,6 +5526,26 @@ where
55375526 res
55385527 }
55395528
5529+ /// Useful if the caller is already triggering a persist of the `ChannelManager`.
5530+ fn send_payment_for_static_invoice_no_persist(
5531+ &self, payment_id: PaymentId, first_hops: Vec<ChannelDetails>,
5532+ ) -> Result<(), Bolt12PaymentError> {
5533+ let best_block_height = self.best_block.read().unwrap().height;
5534+ self.pending_outbound_payments.send_payment_for_static_invoice(
5535+ payment_id,
5536+ &self.router,
5537+ first_hops,
5538+ || self.compute_inflight_htlcs(),
5539+ &self.entropy_source,
5540+ &self.node_signer,
5541+ &self,
5542+ &self.secp_ctx,
5543+ best_block_height,
5544+ &self.pending_events,
5545+ |args| self.send_payment_along_path(args),
5546+ )
5547+ }
5548+
55405549 /// If we are holding an HTLC on behalf of an often-offline sender, this method allows us to
55415550 /// create a path for the sender to use as the reply path when they send the recipient a
55425551 /// [`HeldHtlcAvailable`] onion message, so the recipient's [`ReleaseHeldHtlc`] response will be
0 commit comments