@@ -412,7 +412,8 @@ impl Bolt11Payment {
412412 & self , amount_msat : u64 , description : & Bolt11InvoiceDescription , expiry_secs : u32 ,
413413 ) -> Result < Bolt11Invoice , Error > {
414414 let description = maybe_try_convert_enum ( description) ?;
415- let invoice = self . receive_inner ( Some ( amount_msat) , & description, expiry_secs, None ) ?;
415+ let invoice =
416+ self . receive_inner ( Some ( amount_msat) , & description, expiry_secs, None , None ) ?;
416417 Ok ( maybe_wrap ( invoice) )
417418 }
418419
@@ -435,8 +436,44 @@ impl Bolt11Payment {
435436 payment_hash : PaymentHash ,
436437 ) -> Result < Bolt11Invoice , Error > {
437438 let description = maybe_try_convert_enum ( description) ?;
438- let invoice =
439- self . receive_inner ( Some ( amount_msat) , & description, expiry_secs, Some ( payment_hash) ) ?;
439+ let invoice = self . receive_inner (
440+ Some ( amount_msat) ,
441+ & description,
442+ expiry_secs,
443+ Some ( payment_hash) ,
444+ None ,
445+ ) ?;
446+ Ok ( maybe_wrap ( invoice) )
447+ }
448+
449+ /// Returns a payable invoice that can be used to request a payment of the amount
450+ /// given for the given payment hash.
451+ ///
452+ /// We will register the given payment hash and emit a [`PaymentClaimable`] event once
453+ /// the inbound payment arrives.
454+ ///
455+ /// `min_cltv_expiry_delta` sets the minimum CLTV delta to use for the final hop.
456+ ///
457+ /// **Note:** users *MUST* handle this event and claim the payment manually via
458+ /// [`claim_for_hash`] as soon as they have obtained access to the preimage of the given
459+ /// payment hash. If they're unable to obtain the preimage, they *MUST* immediately fail the payment via
460+ /// [`fail_for_hash`].
461+ ///
462+ /// [`PaymentClaimable`]: crate::Event::PaymentClaimable
463+ /// [`claim_for_hash`]: Self::claim_for_hash
464+ /// [`fail_for_hash`]: Self::fail_for_hash
465+ pub fn receive_for_hash_with_min_cltv_expiry_delta (
466+ & self , amount_msat : u64 , description : & Bolt11InvoiceDescription , expiry_secs : u32 ,
467+ payment_hash : PaymentHash , min_cltv_expiry_delta : u16 ,
468+ ) -> Result < Bolt11Invoice , Error > {
469+ let description = maybe_try_convert_enum ( description) ?;
470+ let invoice = self . receive_inner (
471+ Some ( amount_msat) ,
472+ & description,
473+ expiry_secs,
474+ Some ( payment_hash) ,
475+ Some ( min_cltv_expiry_delta) ,
476+ ) ?;
440477 Ok ( maybe_wrap ( invoice) )
441478 }
442479
@@ -448,7 +485,7 @@ impl Bolt11Payment {
448485 & self , description : & Bolt11InvoiceDescription , expiry_secs : u32 ,
449486 ) -> Result < Bolt11Invoice , Error > {
450487 let description = maybe_try_convert_enum ( description) ?;
451- let invoice = self . receive_inner ( None , & description, expiry_secs, None ) ?;
488+ let invoice = self . receive_inner ( None , & description, expiry_secs, None , None ) ?;
452489 Ok ( maybe_wrap ( invoice) )
453490 }
454491
@@ -470,19 +507,53 @@ impl Bolt11Payment {
470507 & self , description : & Bolt11InvoiceDescription , expiry_secs : u32 , payment_hash : PaymentHash ,
471508 ) -> Result < Bolt11Invoice , Error > {
472509 let description = maybe_try_convert_enum ( description) ?;
473- let invoice = self . receive_inner ( None , & description, expiry_secs, Some ( payment_hash) ) ?;
510+ let invoice =
511+ self . receive_inner ( None , & description, expiry_secs, Some ( payment_hash) , None ) ?;
512+ Ok ( maybe_wrap ( invoice) )
513+ }
514+
515+ /// Returns a payable invoice that can be used to request a payment for the given payment hash
516+ /// and the amount to be determined by the user, also known as a "zero-amount" invoice.
517+ ///
518+ /// We will register the given payment hash and emit a [`PaymentClaimable`] event once
519+ /// the inbound payment arrives.
520+ ///
521+ /// `min_cltv_expiry_delta` sets the minimum CLTV delta to use for the final hop.
522+ ///
523+ /// **Note:** users *MUST* handle this event and claim the payment manually via
524+ /// [`claim_for_hash`] as soon as they have obtained access to the preimage of the given
525+ /// payment hash. If they're unable to obtain the preimage, they *MUST* immediately fail the payment via
526+ /// [`fail_for_hash`].
527+ ///
528+ /// [`PaymentClaimable`]: crate::Event::PaymentClaimable
529+ /// [`claim_for_hash`]: Self::claim_for_hash
530+ /// [`fail_for_hash`]: Self::fail_for_hash
531+ pub fn receive_variable_amount_for_hash_with_min_cltv_expiry_delta (
532+ & self , description : & Bolt11InvoiceDescription , expiry_secs : u32 , payment_hash : PaymentHash ,
533+ min_cltv_expiry_delta : u16 ,
534+ ) -> Result < Bolt11Invoice , Error > {
535+ let description = maybe_try_convert_enum ( description) ?;
536+ let invoice = self . receive_inner (
537+ None ,
538+ & description,
539+ expiry_secs,
540+ Some ( payment_hash) ,
541+ Some ( min_cltv_expiry_delta) ,
542+ ) ?;
474543 Ok ( maybe_wrap ( invoice) )
475544 }
476545
477546 pub ( crate ) fn receive_inner (
478547 & self , amount_msat : Option < u64 > , invoice_description : & LdkBolt11InvoiceDescription ,
479548 expiry_secs : u32 , manual_claim_payment_hash : Option < PaymentHash > ,
549+ min_cltv_expiry_delta : Option < u16 > ,
480550 ) -> Result < LdkBolt11Invoice , Error > {
481551 let invoice = {
482552 let invoice_params = Bolt11InvoiceParameters {
483553 amount_msats : amount_msat,
484554 description : invoice_description. clone ( ) ,
485555 invoice_expiry_delta_secs : Some ( expiry_secs) ,
556+ min_final_cltv_expiry_delta : min_cltv_expiry_delta,
486557 payment_hash : manual_claim_payment_hash,
487558 ..Default :: default ( )
488559 } ;
0 commit comments