@@ -5449,23 +5449,11 @@ where
54495449 fn send_payment_for_static_invoice(
54505450 &self, payment_id: PaymentId,
54515451 ) -> Result<(), Bolt12PaymentError> {
5452- let best_block_height = self.best_block.read().unwrap().height;
54535452 let mut res = Ok(());
5453+ let first_hops = self.list_usable_channels();
54545454 PersistenceNotifierGuard::optionally_notify(self, || {
5455- let outbound_pmts_res = self.pending_outbound_payments.send_payment_for_static_invoice(
5456- payment_id,
5457- &self.router,
5458- self.list_usable_channels(),
5459- || self.compute_inflight_htlcs(),
5460- &self.entropy_source,
5461- &self.node_signer,
5462- &self,
5463- &self.secp_ctx,
5464- best_block_height,
5465- &self.logger,
5466- &self.pending_events,
5467- |args| self.send_payment_along_path(args),
5468- );
5455+ let outbound_pmts_res =
5456+ self.send_payment_for_static_invoice_no_persist(payment_id, first_hops);
54695457 match outbound_pmts_res {
54705458 Err(Bolt12PaymentError::UnexpectedInvoice)
54715459 | Err(Bolt12PaymentError::DuplicateInvoice) => {
@@ -5481,6 +5469,27 @@ where
54815469 res
54825470 }
54835471
5472+ /// Useful if the caller is already triggering a persist of the `ChannelManager`.
5473+ fn send_payment_for_static_invoice_no_persist(
5474+ &self, payment_id: PaymentId, first_hops: Vec<ChannelDetails>,
5475+ ) -> Result<(), Bolt12PaymentError> {
5476+ let best_block_height = self.best_block.read().unwrap().height;
5477+ self.pending_outbound_payments.send_payment_for_static_invoice(
5478+ payment_id,
5479+ &self.router,
5480+ first_hops,
5481+ || self.compute_inflight_htlcs(),
5482+ &self.entropy_source,
5483+ &self.node_signer,
5484+ &self,
5485+ &self.secp_ctx,
5486+ best_block_height,
5487+ &self.logger,
5488+ &self.pending_events,
5489+ |args| self.send_payment_along_path(args),
5490+ )
5491+ }
5492+
54845493 /// If we are holding an HTLC on behalf of an often-offline sender, this method allows us to
54855494 /// create a path for the sender to use as the reply path when they send the recipient a
54865495 /// [`HeldHtlcAvailable`] onion message, so the recipient's [`ReleaseHeldHtlc`] response will be
0 commit comments