@@ -847,13 +847,14 @@ where
847
847
///
848
848
/// Returns an error if the refund targets a different chain or if no valid
849
849
/// blinded path can be constructed.
850
- pub fn create_invoice_builder_from_refund < ' a , ES : Deref , R : Deref > (
851
- & ' a self , router : & R , entropy_source : ES , refund : & ' a Refund , payment_hash : PaymentHash ,
852
- payment_secret : PaymentSecret , usable_channels : Vec < ChannelDetails > ,
850
+ pub fn create_invoice_builder_from_refund < ' a , ES : Deref , R : Deref , F > (
851
+ & ' a self , router : & R , entropy_source : ES , refund : & ' a Refund ,
852
+ usable_channels : Vec < ChannelDetails > , get_payment_info : F ,
853
853
) -> Result < InvoiceBuilder < ' a , DerivedSigningPubkey > , Bolt12SemanticError >
854
854
where
855
855
ES :: Target : EntropySource ,
856
856
R :: Target : Router ,
857
+ F : Fn ( u64 , u32 ) -> Result < ( PaymentHash , PaymentSecret ) , Bolt12SemanticError > ,
857
858
{
858
859
if refund. chain ( ) != self . chain_hash {
859
860
return Err ( Bolt12SemanticError :: UnsupportedChain ) ;
@@ -865,6 +866,8 @@ where
865
866
let amount_msats = refund. amount_msats ( ) ;
866
867
let relative_expiry = DEFAULT_RELATIVE_EXPIRY . as_secs ( ) as u32 ;
867
868
869
+ let ( payment_hash, payment_secret) = get_payment_info ( amount_msats, relative_expiry) ?;
870
+
868
871
let payment_context = PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ;
869
872
let payment_paths = self
870
873
. create_blinded_payment_paths (
@@ -915,20 +918,25 @@ where
915
918
/// - User call the function with [`VerifiedInvoiceRequest<ExplicitSigningPubkey>`].
916
919
/// - Valid blinded payment paths could not be generated for the [`Bolt12Invoice`].
917
920
/// - The [`InvoiceBuilder`] could not be created from the [`InvoiceRequest`].
918
- pub fn create_invoice_builder_from_invoice_request_with_keys < ' a , ES : Deref , R : Deref > (
921
+ pub fn create_invoice_builder_from_invoice_request_with_keys < ' a , ES : Deref , R : Deref , F > (
919
922
& ' a self , router : & R , entropy_source : ES ,
920
- invoice_request : & ' a VerifiedInvoiceRequest < DerivedSigningPubkey > , amount_msats : u64 ,
921
- payment_hash : PaymentHash , payment_secret : PaymentSecret ,
922
- usable_channels : Vec < ChannelDetails > ,
923
+ invoice_request : & ' a VerifiedInvoiceRequest < DerivedSigningPubkey > ,
924
+ usable_channels : Vec < ChannelDetails > , get_payment_info : F ,
923
925
) -> Result < ( InvoiceBuilder < ' a , DerivedSigningPubkey > , MessageContext ) , Bolt12SemanticError >
924
926
where
925
927
ES :: Target : EntropySource ,
926
928
927
929
R :: Target : Router ,
930
+ F : Fn ( u64 , u32 ) -> Result < ( PaymentHash , PaymentSecret ) , Bolt12SemanticError > ,
928
931
{
929
932
let entropy = & * entropy_source;
930
933
let relative_expiry = DEFAULT_RELATIVE_EXPIRY . as_secs ( ) as u32 ;
931
934
935
+ let amount_msats =
936
+ InvoiceBuilder :: < DerivedSigningPubkey > :: amount_msats ( & invoice_request. inner ) ?;
937
+
938
+ let ( payment_hash, payment_secret) = get_payment_info ( amount_msats, relative_expiry) ?;
939
+
932
940
let context = PaymentContext :: Bolt12Offer ( Bolt12OfferContext {
933
941
offer_id : invoice_request. offer_id ,
934
942
invoice_request : invoice_request. fields ( ) ,
@@ -976,19 +984,24 @@ where
976
984
/// - User call the function with [`VerifiedInvoiceRequest<DerivedSigningPubkey>`].
977
985
/// - Valid blinded payment paths could not be generated for the [`Bolt12Invoice`].
978
986
/// - The [`InvoiceBuilder`] could not be created from the [`InvoiceRequest`].
979
- pub fn create_invoice_builder_from_invoice_request_without_keys < ' a , ES : Deref , R : Deref > (
987
+ pub fn create_invoice_builder_from_invoice_request_without_keys < ' a , ES : Deref , R : Deref , F > (
980
988
& ' a self , router : & R , entropy_source : ES ,
981
- invoice_request : & ' a VerifiedInvoiceRequest < ExplicitSigningPubkey > , amount_msats : u64 ,
982
- payment_hash : PaymentHash , payment_secret : PaymentSecret ,
983
- usable_channels : Vec < ChannelDetails > ,
989
+ invoice_request : & ' a VerifiedInvoiceRequest < ExplicitSigningPubkey > ,
990
+ usable_channels : Vec < ChannelDetails > , get_payment_info : F ,
984
991
) -> Result < ( InvoiceBuilder < ' a , ExplicitSigningPubkey > , MessageContext ) , Bolt12SemanticError >
985
992
where
986
993
ES :: Target : EntropySource ,
987
994
R :: Target : Router ,
995
+ F : Fn ( u64 , u32 ) -> Result < ( PaymentHash , PaymentSecret ) , Bolt12SemanticError > ,
988
996
{
989
997
let entropy = & * entropy_source;
990
998
let relative_expiry = DEFAULT_RELATIVE_EXPIRY . as_secs ( ) as u32 ;
991
999
1000
+ let amount_msats =
1001
+ InvoiceBuilder :: < DerivedSigningPubkey > :: amount_msats ( & invoice_request. inner ) ?;
1002
+
1003
+ let ( payment_hash, payment_secret) = get_payment_info ( amount_msats, relative_expiry) ?;
1004
+
992
1005
let context = PaymentContext :: Bolt12Offer ( Bolt12OfferContext {
993
1006
offer_id : invoice_request. offer_id ,
994
1007
invoice_request : invoice_request. fields ( ) ,
0 commit comments