@@ -866,13 +866,14 @@ where
866
866
///
867
867
/// Returns an error if the refund targets a different chain or if no valid
868
868
/// blinded path can be constructed.
869
- pub fn create_invoice_builder_from_refund < ' a , ES : Deref , R : Deref > (
870
- & ' a self , router : & R , entropy_source : ES , refund : & ' a Refund , payment_hash : PaymentHash ,
871
- payment_secret : PaymentSecret , usable_channels : Vec < ChannelDetails > ,
869
+ pub fn create_invoice_builder_from_refund < ' a , ES : Deref , R : Deref , F > (
870
+ & ' a self , router : & R , entropy_source : ES , refund : & ' a Refund ,
871
+ usable_channels : Vec < ChannelDetails > , get_payment_info : F ,
872
872
) -> Result < InvoiceBuilder < ' a , DerivedSigningPubkey > , Bolt12SemanticError >
873
873
where
874
874
ES :: Target : EntropySource ,
875
875
R :: Target : Router ,
876
+ F : Fn ( u64 , u32 ) -> Result < ( PaymentHash , PaymentSecret ) , Bolt12SemanticError > ,
876
877
{
877
878
if refund. chain ( ) != self . chain_hash {
878
879
return Err ( Bolt12SemanticError :: UnsupportedChain ) ;
@@ -884,6 +885,8 @@ where
884
885
let amount_msats = refund. amount_msats ( ) ;
885
886
let relative_expiry = DEFAULT_RELATIVE_EXPIRY . as_secs ( ) as u32 ;
886
887
888
+ let ( payment_hash, payment_secret) = get_payment_info ( amount_msats, relative_expiry) ?;
889
+
887
890
let payment_context = PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ;
888
891
let payment_paths = self
889
892
. create_blinded_payment_paths (
@@ -934,20 +937,25 @@ where
934
937
/// - User call the function with [`VerifiedInvoiceRequest<ExplicitSigningPubkey>`].
935
938
/// - Valid blinded payment paths could not be generated for the [`Bolt12Invoice`].
936
939
/// - The [`InvoiceBuilder`] could not be created from the [`InvoiceRequest`].
937
- pub fn create_invoice_builder_from_invoice_request_with_keys < ' a , ES : Deref , R : Deref > (
940
+ pub fn create_invoice_builder_from_invoice_request_with_keys < ' a , ES : Deref , R : Deref , F > (
938
941
& ' a self , router : & R , entropy_source : ES ,
939
- invoice_request : & ' a VerifiedInvoiceRequest < DerivedSigningPubkey > , amount_msats : u64 ,
940
- payment_hash : PaymentHash , payment_secret : PaymentSecret ,
941
- usable_channels : Vec < ChannelDetails > ,
942
+ invoice_request : & ' a VerifiedInvoiceRequest < DerivedSigningPubkey > ,
943
+ usable_channels : Vec < ChannelDetails > , get_payment_info : F ,
942
944
) -> Result < ( InvoiceBuilder < ' a , DerivedSigningPubkey > , MessageContext ) , Bolt12SemanticError >
943
945
where
944
946
ES :: Target : EntropySource ,
945
947
946
948
R :: Target : Router ,
949
+ F : Fn ( u64 , u32 ) -> Result < ( PaymentHash , PaymentSecret ) , Bolt12SemanticError > ,
947
950
{
948
951
let entropy = & * entropy_source;
949
952
let relative_expiry = DEFAULT_RELATIVE_EXPIRY . as_secs ( ) as u32 ;
950
953
954
+ let amount_msats =
955
+ InvoiceBuilder :: < DerivedSigningPubkey > :: amount_msats ( & invoice_request. inner ) ?;
956
+
957
+ let ( payment_hash, payment_secret) = get_payment_info ( amount_msats, relative_expiry) ?;
958
+
951
959
let context = PaymentContext :: Bolt12Offer ( Bolt12OfferContext {
952
960
offer_id : invoice_request. offer_id ,
953
961
invoice_request : invoice_request. fields ( ) ,
@@ -995,19 +1003,24 @@ where
995
1003
/// - User call the function with [`VerifiedInvoiceRequest<DerivedSigningPubkey>`].
996
1004
/// - Valid blinded payment paths could not be generated for the [`Bolt12Invoice`].
997
1005
/// - The [`InvoiceBuilder`] could not be created from the [`InvoiceRequest`].
998
- pub fn create_invoice_builder_from_invoice_request_without_keys < ' a , ES : Deref , R : Deref > (
1006
+ pub fn create_invoice_builder_from_invoice_request_without_keys < ' a , ES : Deref , R : Deref , F > (
999
1007
& ' a self , router : & R , entropy_source : ES ,
1000
- invoice_request : & ' a VerifiedInvoiceRequest < ExplicitSigningPubkey > , amount_msats : u64 ,
1001
- payment_hash : PaymentHash , payment_secret : PaymentSecret ,
1002
- usable_channels : Vec < ChannelDetails > ,
1008
+ invoice_request : & ' a VerifiedInvoiceRequest < ExplicitSigningPubkey > ,
1009
+ usable_channels : Vec < ChannelDetails > , get_payment_info : F ,
1003
1010
) -> Result < ( InvoiceBuilder < ' a , ExplicitSigningPubkey > , MessageContext ) , Bolt12SemanticError >
1004
1011
where
1005
1012
ES :: Target : EntropySource ,
1006
1013
R :: Target : Router ,
1014
+ F : Fn ( u64 , u32 ) -> Result < ( PaymentHash , PaymentSecret ) , Bolt12SemanticError > ,
1007
1015
{
1008
1016
let entropy = & * entropy_source;
1009
1017
let relative_expiry = DEFAULT_RELATIVE_EXPIRY . as_secs ( ) as u32 ;
1010
1018
1019
+ let amount_msats =
1020
+ InvoiceBuilder :: < DerivedSigningPubkey > :: amount_msats ( & invoice_request. inner ) ?;
1021
+
1022
+ let ( payment_hash, payment_secret) = get_payment_info ( amount_msats, relative_expiry) ?;
1023
+
1011
1024
let context = PaymentContext :: Bolt12Offer ( Bolt12OfferContext {
1012
1025
offer_id : invoice_request. offer_id ,
1013
1026
invoice_request : invoice_request. fields ( ) ,
0 commit comments