@@ -5142,36 +5142,50 @@ where
5142
5142
}
5143
5143
5144
5144
#[cfg(async_payments)]
5145
- #[rustfmt::skip]
5146
5145
fn initiate_async_payment(
5147
- &self, invoice: &StaticInvoice, payment_id: PaymentId
5146
+ &self, invoice: &StaticInvoice, payment_id: PaymentId,
5148
5147
) -> Result<(), Bolt12PaymentError> {
5149
5148
let mut res = Ok(());
5150
5149
PersistenceNotifierGuard::optionally_notify(self, || {
5151
5150
let best_block_height = self.best_block.read().unwrap().height;
5152
5151
let features = self.bolt12_invoice_features();
5153
5152
let outbound_pmts_res = self.pending_outbound_payments.static_invoice_received(
5154
- invoice, payment_id, features, best_block_height, self.duration_since_epoch(),
5155
- &*self.entropy_source, &self.pending_events
5153
+ invoice,
5154
+ payment_id,
5155
+ features,
5156
+ best_block_height,
5157
+ self.duration_since_epoch(),
5158
+ &*self.entropy_source,
5159
+ &self.pending_events,
5156
5160
);
5157
5161
match outbound_pmts_res {
5158
5162
Ok(()) => {},
5159
- Err(Bolt12PaymentError::UnexpectedInvoice) | Err(Bolt12PaymentError::DuplicateInvoice) => {
5163
+ Err(Bolt12PaymentError::UnexpectedInvoice)
5164
+ | Err(Bolt12PaymentError::DuplicateInvoice) => {
5160
5165
res = outbound_pmts_res.map(|_| ());
5161
- return NotifyOption::SkipPersistNoEvents
5166
+ return NotifyOption::SkipPersistNoEvents;
5162
5167
},
5163
5168
Err(e) => {
5164
5169
res = Err(e);
5165
- return NotifyOption::DoPersist
5166
- }
5170
+ return NotifyOption::DoPersist;
5171
+ },
5167
5172
};
5168
5173
5169
5174
let entropy = &*self.entropy_source;
5170
5175
5171
- if self.flow.enqueue_held_htlc_available(entropy, invoice, payment_id, self.get_peers_for_blinded_path()).is_err() {
5172
- self.abandon_payment_with_reason(payment_id, PaymentFailureReason::BlindedPathCreationFailed);
5173
- res = Err(Bolt12PaymentError::BlindedPathCreationFailed);
5174
- return NotifyOption::DoPersist
5176
+ let enqueue_held_htlc_available_res = self.flow.enqueue_held_htlc_available(
5177
+ entropy,
5178
+ invoice,
5179
+ payment_id,
5180
+ self.get_peers_for_blinded_path(),
5181
+ );
5182
+ if enqueue_held_htlc_available_res.is_err() {
5183
+ self.abandon_payment_with_reason(
5184
+ payment_id,
5185
+ PaymentFailureReason::BlindedPathCreationFailed,
5186
+ );
5187
+ res = Err(Bolt12PaymentError::BlindedPathCreationFailed);
5188
+ return NotifyOption::DoPersist;
5175
5189
};
5176
5190
5177
5191
NotifyOption::DoPersist
@@ -5181,27 +5195,36 @@ where
5181
5195
}
5182
5196
5183
5197
#[cfg(async_payments)]
5184
- #[rustfmt::skip]
5185
5198
fn send_payment_for_static_invoice(
5186
- &self, payment_id: PaymentId
5199
+ &self, payment_id: PaymentId,
5187
5200
) -> Result<(), Bolt12PaymentError> {
5188
5201
let best_block_height = self.best_block.read().unwrap().height;
5189
5202
let mut res = Ok(());
5190
5203
PersistenceNotifierGuard::optionally_notify(self, || {
5191
5204
let outbound_pmts_res = self.pending_outbound_payments.send_payment_for_static_invoice(
5192
- payment_id, &self.router, self.list_usable_channels(), || self.compute_inflight_htlcs(),
5193
- &self.entropy_source, &self.node_signer, &self, &self.secp_ctx, best_block_height,
5194
- &self.logger, &self.pending_events, |args| self.send_payment_along_path(args)
5205
+ payment_id,
5206
+ &self.router,
5207
+ self.list_usable_channels(),
5208
+ || self.compute_inflight_htlcs(),
5209
+ &self.entropy_source,
5210
+ &self.node_signer,
5211
+ &self,
5212
+ &self.secp_ctx,
5213
+ best_block_height,
5214
+ &self.logger,
5215
+ &self.pending_events,
5216
+ |args| self.send_payment_along_path(args),
5195
5217
);
5196
5218
match outbound_pmts_res {
5197
- Err(Bolt12PaymentError::UnexpectedInvoice) | Err(Bolt12PaymentError::DuplicateInvoice) => {
5219
+ Err(Bolt12PaymentError::UnexpectedInvoice)
5220
+ | Err(Bolt12PaymentError::DuplicateInvoice) => {
5198
5221
res = outbound_pmts_res.map(|_| ());
5199
5222
NotifyOption::SkipPersistNoEvents
5200
5223
},
5201
5224
other_res => {
5202
5225
res = other_res;
5203
5226
NotifyOption::DoPersist
5204
- }
5227
+ },
5205
5228
}
5206
5229
});
5207
5230
res
@@ -10719,9 +10742,8 @@ where
10719
10742
/// created via [`Self::create_async_receive_offer_builder`]. If `relative_expiry` is unset, the
10720
10743
/// invoice's expiry will default to [`STATIC_INVOICE_DEFAULT_RELATIVE_EXPIRY`].
10721
10744
#[cfg(async_payments)]
10722
- #[rustfmt::skip]
10723
10745
pub fn create_static_invoice_builder<'a>(
10724
- &self, offer: &'a Offer, offer_nonce: Nonce, relative_expiry: Option<Duration>
10746
+ &self, offer: &'a Offer, offer_nonce: Nonce, relative_expiry: Option<Duration>,
10725
10747
) -> Result<StaticInvoiceBuilder<'a>, Bolt12SemanticError> {
10726
10748
let entropy = &*self.entropy_source;
10727
10749
let amount_msat = offer.amount().and_then(|amount| match amount {
@@ -10734,13 +10756,23 @@ where
10734
10756
10735
10757
let created_at = self.duration_since_epoch();
10736
10758
let payment_secret = inbound_payment::create_for_spontaneous_payment(
10737
- &self.inbound_payment_key, amount_msat, relative_expiry_secs, created_at.as_secs(), None
10738
- ).map_err(|()| Bolt12SemanticError::InvalidAmount)?;
10759
+ &self.inbound_payment_key,
10760
+ amount_msat,
10761
+ relative_expiry_secs,
10762
+ created_at.as_secs(),
10763
+ None,
10764
+ )
10765
+ .map_err(|()| Bolt12SemanticError::InvalidAmount)?;
10739
10766
10740
10767
self.flow.create_static_invoice_builder(
10741
- &self.router, entropy, offer, offer_nonce, payment_secret,
10742
- relative_expiry_secs, self.list_usable_channels(),
10743
- self.get_peers_for_blinded_path()
10768
+ &self.router,
10769
+ entropy,
10770
+ offer,
10771
+ offer_nonce,
10772
+ payment_secret,
10773
+ relative_expiry_secs,
10774
+ self.list_usable_channels(),
10775
+ self.get_peers_for_blinded_path(),
10744
10776
)
10745
10777
}
10746
10778
0 commit comments