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