@@ -85,8 +85,8 @@ use crate::ln::our_peer_storage::{EncryptedOurPeerStorage, PeerStorageMonitorHol
8585#[cfg(test)]
8686use crate::ln::outbound_payment;
8787use crate::ln::outbound_payment::{
88- OutboundPayments, PendingOutboundPayment, RetryableInvoiceRequest, SendAlongPathArgs ,
89- StaleExpiration,
88+ OutboundPayments, PendingOutboundPayment, RecipientCustomTlvs, RetryableInvoiceRequest ,
89+ SendAlongPathArgs, StaleExpiration,
9090};
9191use crate::ln::types::ChannelId;
9292use crate::offers::async_receive_offer_cache::AsyncReceiveOfferCache;
@@ -674,6 +674,36 @@ impl Readable for InterceptId {
674674 }
675675}
676676
677+ /// Optional arguments to [`ChannelManager::pay_for_bolt11_invoice`]
678+ ///
679+ /// These fields will often not need to be set, and the provided [`Self::default`] can be used.
680+ pub struct OptionalBolt11PaymentParams {
681+ /// A set of custom tlvs, user can send along the payment.
682+ pub custom_tlvs: RecipientCustomTlvs,
683+ /// Pathfinding options which tweak how the path is constructed to the recipient.
684+ pub route_params_config: RouteParametersConfig,
685+ /// The number of tries or time during which we'll retry this payment if some paths to the
686+ /// recipient fail.
687+ ///
688+ /// Once the retry limit is reached, further path failures will not be retried and the payment
689+ /// will ultimately fail once all pending paths have failed (generating an
690+ /// [`Event::PaymentFailed`]).
691+ pub retry_strategy: Retry,
692+ }
693+
694+ impl Default for OptionalBolt11PaymentParams {
695+ fn default() -> Self {
696+ Self {
697+ custom_tlvs: RecipientCustomTlvs::new(vec![]).unwrap(),
698+ route_params_config: Default::default(),
699+ #[cfg(feature = "std")]
700+ retry_strategy: Retry::Timeout(core::time::Duration::from_secs(2)),
701+ #[cfg(not(feature = "std"))]
702+ retry_strategy: Retry::Attempts(3),
703+ }
704+ }
705+ }
706+
677707/// Optional arguments to [`ChannelManager::pay_for_offer`]
678708#[cfg_attr(
679709 feature = "dnssec",
@@ -2277,19 +2307,19 @@ where
22772307/// # use bitcoin::hashes::Hash;
22782308/// # use lightning::events::{Event, EventsProvider};
22792309/// # use lightning::types::payment::PaymentHash;
2280- /// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
2281- /// # use lightning::routing::router::RouteParametersConfig;
2310+ /// # use lightning::ln::channelmanager::{AChannelManager, OptionalBolt11PaymentParams, PaymentId, RecentPaymentDetails, Retry};
22822311/// # use lightning_invoice::Bolt11Invoice;
22832312/// #
22842313/// # fn example<T: AChannelManager>(
2285- /// # channel_manager: T, invoice: &Bolt11Invoice, route_params_config: RouteParametersConfig ,
2314+ /// # channel_manager: T, invoice: &Bolt11Invoice, optional_params: OptionalBolt11PaymentParams ,
22862315/// # retry: Retry
22872316/// # ) {
22882317/// # let channel_manager = channel_manager.get_cm();
22892318/// # let payment_id = PaymentId([42; 32]);
22902319/// # let payment_hash = invoice.payment_hash();
2320+ ///
22912321/// match channel_manager.pay_for_bolt11_invoice(
2292- /// invoice, payment_id, None, route_params_config, retry
2322+ /// invoice, payment_id, None, optional_params
22932323/// ) {
22942324/// Ok(()) => println!("Sending payment with hash {}", payment_hash),
22952325/// Err(e) => println!("Failed sending payment with hash {}: {:?}", payment_hash, e),
@@ -5498,16 +5528,15 @@ where
54985528 /// To use default settings, call the function with [`RouteParametersConfig::default`].
54995529 pub fn pay_for_bolt11_invoice(
55005530 &self, invoice: &Bolt11Invoice, payment_id: PaymentId, amount_msats: Option<u64>,
5501- route_params_config: RouteParametersConfig, retry_strategy: Retry ,
5531+ optional_params: OptionalBolt11PaymentParams ,
55025532 ) -> Result<(), Bolt11PaymentError> {
55035533 let best_block_height = self.best_block.read().unwrap().height;
55045534 let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
55055535 self.pending_outbound_payments.pay_for_bolt11_invoice(
55065536 invoice,
55075537 payment_id,
55085538 amount_msats,
5509- route_params_config,
5510- retry_strategy,
5539+ optional_params,
55115540 &self.router,
55125541 self.list_usable_channels(),
55135542 || self.compute_inflight_htlcs(),
0 commit comments