@@ -987,7 +987,7 @@ where
987987
988988 pub ( crate ) async fn lsps2_receive_to_jit_channel (
989989 & self , amount_msat : u64 , description : & Bolt11InvoiceDescription , expiry_secs : u32 ,
990- max_total_lsp_fee_limit_msat : Option < u64 > ,
990+ max_total_lsp_fee_limit_msat : Option < u64 > , payment_hash : Option < PaymentHash > ,
991991 ) -> Result < ( Bolt11Invoice , u64 ) , Error > {
992992 let fee_response = self . lsps2_request_opening_fee_params ( ) . await ?;
993993
@@ -1039,6 +1039,7 @@ where
10391039 Some ( amount_msat) ,
10401040 description,
10411041 expiry_secs,
1042+ payment_hash,
10421043 ) ?;
10431044
10441045 log_info ! ( self . logger, "JIT-channel invoice created: {}" , invoice) ;
@@ -1047,7 +1048,7 @@ where
10471048
10481049 pub ( crate ) async fn lsps2_receive_variable_amount_to_jit_channel (
10491050 & self , description : & Bolt11InvoiceDescription , expiry_secs : u32 ,
1050- max_proportional_lsp_fee_limit_ppm_msat : Option < u64 > ,
1051+ max_proportional_lsp_fee_limit_ppm_msat : Option < u64 > , payment_hash : Option < PaymentHash > ,
10511052 ) -> Result < ( Bolt11Invoice , u64 ) , Error > {
10521053 let fee_response = self . lsps2_request_opening_fee_params ( ) . await ?;
10531054
@@ -1081,8 +1082,13 @@ where
10811082 ) ;
10821083
10831084 let buy_response = self . lsps2_send_buy_request ( None , min_opening_params) . await ?;
1084- let invoice =
1085- self . lsps2_create_jit_invoice ( buy_response, None , description, expiry_secs) ?;
1085+ let invoice = self . lsps2_create_jit_invoice (
1086+ buy_response,
1087+ None ,
1088+ description,
1089+ expiry_secs,
1090+ payment_hash,
1091+ ) ?;
10861092
10871093 log_info ! ( self . logger, "JIT-channel invoice created: {}" , invoice) ;
10881094 Ok ( ( invoice, min_prop_fee_ppm_msat) )
@@ -1165,18 +1171,36 @@ where
11651171 fn lsps2_create_jit_invoice (
11661172 & self , buy_response : LSPS2BuyResponse , amount_msat : Option < u64 > ,
11671173 description : & Bolt11InvoiceDescription , expiry_secs : u32 ,
1174+ payment_hash : Option < PaymentHash > ,
11681175 ) -> Result < Bolt11Invoice , Error > {
11691176 let lsps2_client = self . lsps2_client . as_ref ( ) . ok_or ( Error :: LiquiditySourceUnavailable ) ?;
11701177
11711178 // LSPS2 requires min_final_cltv_expiry_delta to be at least 2 more than usual.
11721179 let min_final_cltv_expiry_delta = MIN_FINAL_CLTV_EXPIRY_DELTA + 2 ;
1173- let ( payment_hash, payment_secret) = self
1174- . channel_manager
1175- . create_inbound_payment ( None , expiry_secs, Some ( min_final_cltv_expiry_delta) )
1176- . map_err ( |e| {
1177- log_error ! ( self . logger, "Failed to register inbound payment: {:?}" , e) ;
1178- Error :: InvoiceCreationFailed
1179- } ) ?;
1180+ let ( payment_hash, payment_secret) = match payment_hash {
1181+ Some ( payment_hash) => {
1182+ let payment_secret = self
1183+ . channel_manager
1184+ . create_inbound_payment_for_hash (
1185+ payment_hash,
1186+ None ,
1187+ expiry_secs,
1188+ Some ( min_final_cltv_expiry_delta) ,
1189+ )
1190+ . map_err ( |e| {
1191+ log_error ! ( self . logger, "Failed to register inbound payment: {:?}" , e) ;
1192+ Error :: InvoiceCreationFailed
1193+ } ) ?;
1194+ ( payment_hash, payment_secret)
1195+ } ,
1196+ None => self
1197+ . channel_manager
1198+ . create_inbound_payment ( None , expiry_secs, Some ( min_final_cltv_expiry_delta) )
1199+ . map_err ( |e| {
1200+ log_error ! ( self . logger, "Failed to register inbound payment: {:?}" , e) ;
1201+ Error :: InvoiceCreationFailed
1202+ } ) ?,
1203+ } ;
11801204
11811205 let route_hint = RouteHint ( vec ! [ RouteHintHop {
11821206 src_node_id: lsps2_client. lsp_node_id,
0 commit comments