@@ -696,16 +696,6 @@ impl Readable for InterceptId {
696
696
///
697
697
/// These fields will often not need to be set, and the provided [`Self::default`] can be used.
698
698
pub struct OptionalOfferPaymentInfo {
699
- /// The quantity of the offer which we wish to pay for. This is communicated to the recipient
700
- /// and determines the minimum value which we must pay.
701
- ///
702
- /// This must be set if we're paying for an offer that has [`Offer::expects_quantity`].
703
- ///
704
- #[cfg_attr(
705
- feature = "dnssec",
706
- doc = "Note that setting this will cause [`ChannelManager::pay_for_offer_from_human_readable_name`] to fail."
707
- )]
708
- pub quantity: Option<u64>,
709
699
/// A note which is communicated to the recipient about this payment via
710
700
/// [`InvoiceRequest::payer_note`].
711
701
pub payer_note: Option<String>,
@@ -723,7 +713,6 @@ pub struct OptionalOfferPaymentInfo {
723
713
impl Default for OptionalOfferPaymentInfo {
724
714
fn default() -> Self {
725
715
Self {
726
- quantity: None,
727
716
payer_note: None,
728
717
route_params_config: Default::default(),
729
718
#[cfg(feature = "std")]
@@ -11212,8 +11201,6 @@ where
11212
11201
/// request.
11213
11202
///
11214
11203
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
11215
- /// [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
11216
- /// [`InvoiceRequest::payer_note`]: crate::offers::invoice_request::InvoiceRequest::payer_note
11217
11204
/// [`InvoiceRequestBuilder`]: crate::offers::invoice_request::InvoiceRequestBuilder
11218
11205
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
11219
11206
/// [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath
@@ -11243,7 +11230,55 @@ where
11243
11230
11244
11231
self.pay_for_offer_intern(
11245
11232
offer,
11246
- optional_info.quantity,
11233
+ if offer.expects_quantity() { Some(1) } else { None },
11234
+ amount_msats,
11235
+ optional_info.payer_note,
11236
+ payment_id,
11237
+ None,
11238
+ create_pending_payment_fn,
11239
+ )
11240
+ }
11241
+
11242
+ /// Pays for an [`Offer`] using the given parameters, including a `quantity`, by creating an
11243
+ /// [`InvoiceRequest`] and enqueuing it to be sent via an onion message. [`ChannelManager`] will
11244
+ /// pay the actual [`Bolt12Invoice`] once it is received.
11245
+ ///
11246
+ /// This method is identical to [`Self::pay_for_offer`] with the one exception that it allows
11247
+ /// you to specify the [`InvoiceRequest::quantity`]. We expect this to be rather seldom used,
11248
+ /// as the "quantity" feature of offers doesn't line up with common payment flows today.
11249
+ ///
11250
+ /// This method is otherwise identical to [`Self::pay_for_offer`] but will additionally fail if
11251
+ /// the provided `quantity` does not meet the requirements described by
11252
+ /// [`Offer::supported_quantity`].
11253
+ ///
11254
+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
11255
+ /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
11256
+ /// [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
11257
+ pub fn pay_for_offer_with_quantity(
11258
+ &self, offer: &Offer, amount_msats: Option<u64>, payment_id: PaymentId,
11259
+ optional_info: OptionalOfferPaymentInfo, quantity: u64,
11260
+ ) -> Result<(), Bolt12SemanticError> {
11261
+ let create_pending_payment_fn = |invoice_request: &InvoiceRequest, nonce| {
11262
+ let expiration = StaleExpiration::TimerTicks(1);
11263
+ let retryable_invoice_request = RetryableInvoiceRequest {
11264
+ invoice_request: invoice_request.clone(),
11265
+ nonce,
11266
+ needs_retry: true,
11267
+ };
11268
+ self.pending_outbound_payments
11269
+ .add_new_awaiting_invoice(
11270
+ payment_id,
11271
+ expiration,
11272
+ optional_info.retry_strategy,
11273
+ optional_info.route_params_config,
11274
+ Some(retryable_invoice_request),
11275
+ )
11276
+ .map_err(|_| Bolt12SemanticError::DuplicatePaymentId)
11277
+ };
11278
+
11279
+ self.pay_for_offer_intern(
11280
+ offer,
11281
+ Some(quantity),
11247
11282
amount_msats,
11248
11283
optional_info.payer_note,
11249
11284
payment_id,
@@ -11378,9 +11413,7 @@ where
11378
11413
///
11379
11414
/// # Errors
11380
11415
///
11381
- /// Errors if:
11382
- /// - a duplicate `payment_id` is provided given the caveats in the aforementioned link,
11383
- /// - [`OptionalOfferPaymentInfo.quantity`] is set.
11416
+ /// Errors if a duplicate `payment_id` is provided given the caveats in the aforementioned link.
11384
11417
///
11385
11418
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
11386
11419
/// [bLIP 32]: https://github.com/lightning/blips/blob/master/blip-0032.md
@@ -11396,10 +11429,6 @@ where
11396
11429
&self, name: HumanReadableName, amount_msats: u64, payment_id: PaymentId,
11397
11430
optional_info: OptionalOfferPaymentInfo, dns_resolvers: Vec<Destination>,
11398
11431
) -> Result<(), ()> {
11399
- if optional_info.quantity.is_some() {
11400
- return Err(());
11401
- }
11402
-
11403
11432
let (onion_message, context) =
11404
11433
self.flow.hrn_resolver.resolve_name(payment_id, name, &*self.entropy_source)?;
11405
11434
0 commit comments