@@ -987,7 +987,7 @@ where
987
987
988
988
pub ( crate ) async fn lsps2_receive_to_jit_channel (
989
989
& 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 > ,
991
991
) -> Result < ( Bolt11Invoice , u64 ) , Error > {
992
992
let fee_response = self . lsps2_request_opening_fee_params ( ) . await ?;
993
993
@@ -1039,6 +1039,7 @@ where
1039
1039
Some ( amount_msat) ,
1040
1040
description,
1041
1041
expiry_secs,
1042
+ payment_hash,
1042
1043
) ?;
1043
1044
1044
1045
log_info ! ( self . logger, "JIT-channel invoice created: {}" , invoice) ;
@@ -1047,7 +1048,7 @@ where
1047
1048
1048
1049
pub ( crate ) async fn lsps2_receive_variable_amount_to_jit_channel (
1049
1050
& 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 > ,
1051
1052
) -> Result < ( Bolt11Invoice , u64 ) , Error > {
1052
1053
let fee_response = self . lsps2_request_opening_fee_params ( ) . await ?;
1053
1054
@@ -1081,8 +1082,13 @@ where
1081
1082
) ;
1082
1083
1083
1084
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
+ ) ?;
1086
1092
1087
1093
log_info ! ( self . logger, "JIT-channel invoice created: {}" , invoice) ;
1088
1094
Ok ( ( invoice, min_prop_fee_ppm_msat) )
@@ -1165,18 +1171,36 @@ where
1165
1171
fn lsps2_create_jit_invoice (
1166
1172
& self , buy_response : LSPS2BuyResponse , amount_msat : Option < u64 > ,
1167
1173
description : & Bolt11InvoiceDescription , expiry_secs : u32 ,
1174
+ payment_hash : Option < PaymentHash > ,
1168
1175
) -> Result < Bolt11Invoice , Error > {
1169
1176
let lsps2_client = self . lsps2_client . as_ref ( ) . ok_or ( Error :: LiquiditySourceUnavailable ) ?;
1170
1177
1171
1178
// LSPS2 requires min_final_cltv_expiry_delta to be at least 2 more than usual.
1172
1179
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
+ } ;
1180
1204
1181
1205
let route_hint = RouteHint ( vec ! [ RouteHintHop {
1182
1206
src_node_id: lsps2_client. lsp_node_id,
0 commit comments